标签:function color int div public false turn determine power
Given an integer, write a function to determine if it is a power of two.
1 public class Solution { 2 public bool IsPowerOfTwo(int n) { 3 if (n <= 0) return false; 4 if (n <= 2) return true; 5 6 while (n > 2) 7 { 8 if (n % 2 != 0) return false; 9 n = n / 2; 10 } 11 12 return true; 13 } 14 }
标签:function color int div public false turn determine power
原文地址:http://www.cnblogs.com/liangmou/p/7965674.html