isPowerOfTwo function

bool isPowerOfTwo(
  1. int number
)

Find out whether the provided integer is a perfect power of two.

True if and only if it is a power of two.

Implementation

bool isPowerOfTwo(int number) => number > 0 && (number & (number - 1)) == 0;