Adobe Interview Question
Software Engineer / Developerslol... the count is itself "n"...what to count then ...WTF ...either there's something missing or question is disgustingly dumb!
In question , they asked that give the number of 1's in given number.
for example : number = 10 the 00001010 so number of 1's = 2
I will write C code we can convert later on
int numberofone = 0;
If ( number > 0 )
numberofone = 1;
while ( number > 0 )
{
if ( number & (number - 1 ) )
numberofone++;
number = number >> 1;
}
return numberofone;
In question , they asked that give the number of 1's in given number.
for example : number = 10 the 00001010 so number of 1's = 2
I will write C code we can convert later on
int numberofone = 0;
If ( number > 0 )
numberofone = 1;
while ( number > 0 )
{
if ( number & (number - 1 ) )
numberofone++;
number = number >> 1;
}
return numberofone;
Which instruction set?
- LOLer July 31, 2009Also, count 1st n numbers? Isn't the answer n?