Microsoft Interview Question
1,272 Interview Reviews |
Back to all Microsoft Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Development Engineer at Microsoft:
write a boolean method to find out if a number is a power of 2
See more for this Microsoft Software Development Engineer Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (4)
0 of 2 people found this helpful
My solution:
bool IsPowerOfTwo(int n)
{
int val;
return Int32.TryParse(Math.Sqrt(num).ToString(), out val);
}
Helpful Answer?
Yes |
No
Inappropriate?
Helpful Answer?
Yes |
No
Inappropriate?
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up



2 of 4 people found this helpful
by dpetek:
return (n & (-n)) == n;
}