1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/4的幂 [power-of-four].html
2022-03-29 12:43:11 +08:00

39 lines
885 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给定一个整数,写一个函数来判断它是否是 4 的幂次方。如果是,返回 <code>true</code> ;否则,返回 <code>false</code></p>
<p>整数 <code>n</code> 是 4 的幂次方需满足:存在整数 <code>x</code> 使得 <code>n == 4<sup>x</sup></code></p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 16
<strong>输出:</strong>true
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>n = 5
<strong>输出:</strong>false
</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>n = 1
<strong>输出:</strong>true
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>-2<sup>31</sup> &lt;= n &lt;= 2<sup>31</sup> - 1</code></li>
</ul>
<p>&nbsp;</p>
<p><strong>进阶:</strong>你能不使用循环或者递归来完成本题吗?</p>