Contact: aviboots(AT)netvision.net.il
32,304 questions
42,479 answers
573 users
object CheckIfANumberIsPowerOf2_Scala { def isPowerOfTwo(n: Int): Boolean = { n > 0 && ((n & (n - 1)) == 0) } def main(args: Array[String]): Unit = { val n = 32 // = 2 ^ 5 println(isPowerOfTwo(n)) } } /* run: true */