Easy · Math

Is power of two

Given an integer n, return true if n is a power of two (n = 2^k for some integer k ≥ 0), and false otherwise; 0 and negative numbers are never powers of two.

Examples

Example 1

n = 8

Output: true

Example 2

n = 6

Output: false

Rebuild it in the studio

Open every published interview problem, solution, scene, and memory room free, with no account.

More Math problems