当前位置:网站首页>[daily training] 326 Power of 3
[daily training] 326 Power of 3
2022-07-01 22:50:00 【Puppet__】
subject
Given an integer , Write a function to determine if it is 3 Power square . If it is , return true ; otherwise , return false .
Integers n yes 3 To the power of : There are integers x bring n == 3x
Example 1:
Input :n = 27
Output :true
Example 2:
Input :n = 0
Output :false
Example 3:
Input :n = 9
Output :true
Example 4:
Input :n = 45
Output :false
Tips :
-231<= n <= 231 - 1
Code
package dayLeetCode;
public class dayleetcode326 {
public boolean isPowerOfThree(int n) {
if (n == 0){
return false;
}
while (n != 0 && n % 3 == 0){
n /= 3;
}
if (n == 1){
return true;
}else {
return false;
}
}
public static void main(String[] args) {
dayleetcode326 obj = new dayleetcode326();
System.out.println(obj.isPowerOfThree(27));
}
}
边栏推荐
- Niuke monthly race - logarithmic sum in groups
- Redis configuration and optimization
- MySQL view exercise
- MySQL中对于事务的理解
- 倒置残差的理解
- Using securecrtportable to remotely connect virtual machines
- 固定资产管理子系统报表分为什么大类,包括哪些科目
- How to write a performance test plan
- Pytorch's code for visualizing feature maps after training its own network
- 阿洛迷茫后的思考
猜你喜欢

Learn MySQL from scratch - database and data table operations

激发新动能 多地发力数字经济

YOLOv5.5 调用本地摄像头

The second anniversary of the three winged bird: the wings are getting richer and the take-off is just around the corner

每日刷题记录 (十)

Slope compensation

切面条 C语言

Metauniverse may become a new direction of Internet development

好友新书发布,祝贺(送福利)

Appium自动化测试基础 — APPium安装(一)
随机推荐
【日常训练】326. 3 的幂
Mixconv code
447 Bili Bili noodles warp 1
Lc669. Prune binary search tree
【JetCache】JetCache的使用方法与步骤
【无标题】
FFMpeg学习笔记
awoo‘s Favorite Problem(优先队列)
flink sql 命令行 连接 yarn
Fiori 应用通过 Adaptation Project 的增强方式分享
twenty million two hundred and twenty thousand seven hundred and one
下班前几分钟,我弄清了v-model与.sync的区别
园区全光技术选型-中篇
Measurement of reference loop gain and phase margin
倒置残差的理解
好友新书发布,祝贺(送福利)
性能测试计划怎么编写
元宇宙可能成为互联网发展的新方向
分享一个一年经历两次裁员的程序员的一些感触
nn.Parameter】Pytorch特征融合自适应权重设置(可学习权重使用)