Tap here to switch tabs
Problem
Submissions

Problem: Power of Two

Power of Two asks whether a given integer can be expressed as two raised to an integer exponent. Return TRUE for powers of two and FALSE otherwise, including negative values.

Statement

An integer n is considered a power of two if it can be expressed as n ==2x==2^x, where xx is an integer.

Determine whether a given integer n is a power of two. If it is, then return TRUE; otherwise, return FALSE.

Constraints:

  • −231≤-2^{31} \leq n ≤231−1\leq 2^{31} - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Power of Two

Power of Two asks whether a given integer can be expressed as two raised to an integer exponent. Return TRUE for powers of two and FALSE otherwise, including negative values.

Statement

An integer n is considered a power of two if it can be expressed as n ==2x==2^x, where xx is an integer.

Determine whether a given integer n is a power of two. If it is, then return TRUE; otherwise, return FALSE.

Constraints:

  • −231≤-2^{31} \leq n ≤231−1\leq 2^{31} - 1