当前位置:网站首页>[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));
}
}
边栏推荐
- MySQL的存储过程
- [QT widget] encapsulates a simple thread management class
- 利用SecureCRTPortable远程连接虚拟机
- nn. Parameter] pytoch feature fusion adaptive weight setting (learnable weight use)
- 【扫盲】机器学习图像处理中的深层/浅层、局部/全局特征
- Understanding of transactions in MySQL
- 隐藏用户的创建和使用
- Wechat open platform scanning code login [easy to understand]
- Little red book scheme jumps to the specified page
- Mysql5.7 set password policy (etc. three-level password transformation)
猜你喜欢

SAP UI5 应用开发教程之一百零四 - SAP UI5 表格控件的支持复选(Multi-Select)以及如何用代码一次选中多个表格行项目

Slope compensation

rxjs Observable of 操作符的单步调试分析

Share some feelings of a programmer who has experienced layoffs twice a year

Favorite transaction code management tool in SAP GUI

Appium自动化测试基础 — 补充:Desired Capabilities参数介绍

Appium automation test foundation - appium installation (I)

元宇宙可能成为互联网发展的新方向

map容器

配置筛选机
随机推荐
Metauniverse may become a new direction of Internet development
Friendly serial assistant tutorial_ How to configure friendly serial port debugging assistant - tutorial on using friendly serial port debugging assistant
使用 Three.js 实现'雪糕'地球,让地球也凉爽一夏
Today's sleep quality record 71 points
cvpr2022 human pose estiamtion
QStringList 的常规使用
Awoo's favorite problem (priority queue)
General use of qstringlist
Favorite transaction code management tool in SAP GUI
MySQL stored procedure
MySQL数据库详细学习教程
【扫盲】机器学习图像处理中的深层/浅层、局部/全局特征
447 Bili Bili noodles warp 1
【c语言】malloc函数详解[通俗易懂]
Tourism Management System
Appium automated testing foundation - Supplement: introduction to desired capabilities parameters
Niuke monthly race - logarithmic sum in groups
flink sql 命令行 连接 yarn
园区全光技术选型-中篇
内部字段分隔符