当前位置:网站首页>[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));
}
}
边栏推荐
- 切面条 C语言
- Ffmpeg learning notes
- MySQL的视图练习题
- Object memory layout
- 性能测试计划怎么编写
- H5 model trained by keras to tflite
- Lc669. Prune binary search tree
- The fixed assets management subsystem reports are divided into what categories and which accounts are included
- 3DE 资源没东西或不对
- spark analyze命令使用及其作用 map join broadcast join 广播join
猜你喜欢

Learn MySQL from scratch - database and data table operations

SAP GUI 里的收藏夹事务码管理工具

Mysql5.7 set password policy (etc. three-level password transformation)

The fixed assets management subsystem reports are divided into what categories and which accounts are included

Fiori 应用通过 Adaptation Project 的增强方式分享

正则系列之量词(Quantifiers)

Intelligent computing architecture design of Internet

The median salary of TSMC's global employees is about 460000, and the CEO is about 8.99 million; Apple raised the price of iPhone in Japan; VIM 9.0 release | geek headlines

每日刷题记录 (十)

【图像分割】2021-SegFormer NeurIPS
随机推荐
nn.Parameter】Pytorch特征融合自适应权重设置(可学习权重使用)
SAP 智能机器人流程自动化(iRPA)解决方案分享
LC501. 二叉搜索树中的众数
Use three JS realize the 'ice cream' earth, and let the earth cool for a summer
flink sql 命令行 连接 yarn
Friendly serial assistant tutorial_ How to configure friendly serial port debugging assistant - tutorial on using friendly serial port debugging assistant
Selection of all-optical technology in the park - Part 2
Configure filter
使用 Three.js 实现'雪糕'地球,让地球也凉爽一夏
447-哔哩哔哩面经1
Yyds dry goods inventory # solve the real problem of famous enterprises: egg twisting machine
【目标跟踪】|单目标跟踪指标
mixconv代码
Dark horse programmer - software testing - stage 06 2-linux and database-01-08 Chapter 1 - description of the content of the Linux operating system stage, description of the basic format and common fo
spark analyze命令使用及其作用 map join broadcast join 广播join
元宇宙可能成为互联网发展的新方向
分享一个一年经历两次裁员的程序员的一些感触
Pytorch nn.functional.unfold()的简单理解与用法
Yolov5.5 call local camera
搜狗微信APP逆向(二)so层