B. Luỹ thừa của 2


Submit solution

Points: 50
Time limit: 1.0s
Memory limit: 256M

Problem type

Cho một số nguyên n, hãy trả về true nếu n là một lũy thừa của 2. Ngược lại, trả về false.

Một số nguyên n là lũy thừa của 2 nếu tồn tại một số nguyên x sao cho:

n == 2^x
Ví dụ:

Ví dụ 1:

Input: n = 1
Output: true
Giải thích: 2⁰ = 1

Ví dụ 2:

Input: n = 16
Output: true
Giải thích: 2⁴ = 16

Ví dụ 3:

Input: n = 3
Output: false

Comments

There are no comments at the moment.