当前位置:网站首页>[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));
}
}
边栏推荐
- Understanding of indexes in MySQL
- cvpr2022 human pose estiamtion
- SAP UI5 应用开发教程之一百零四 - SAP UI5 表格控件的支持复选(Multi-Select)以及如何用代码一次选中多个表格行项目
- Cut noodles C language
- MySQL的存储过程
- RestTemplate 远程调用工具类
- Selection of all-optical technology in the park - Part 2
- 微信开放平台扫码登录[通俗易懂]
- H5 model trained by keras to tflite
- 友善串口助手使用教程_友善串口调试助手怎么进行配置-友善串口调试助手使用教程…
猜你喜欢

Slope compensation

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

Rust语言——小小白的入门学习05

Cut noodles C language

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

Appium自动化测试基础 — APPium安装(一)

性能测试计划怎么编写

配置筛选机

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

Appium automated testing foundation - Supplement: introduction to desired capabilities parameters
随机推荐
QT uses ffmpeg4 to convert the qimage of ARGB to yuv422p
MySQL5.7 设置密码策略(等保三级密码改造)
Wechat open platform scanning code login [easy to understand]
Favorite transaction code management tool in SAP GUI
Origin2018安装教程「建议收藏」
SAP intelligent robot process automation (IRPA) solution sharing
[QT widget] encapsulates a simple thread management class
Pytorch nn. functional. Simple understanding and usage of unfold()
LC501. Mode in binary search tree
【图像分割】2021-SegFormer NeurIPS
Understanding of indexes in MySQL
Multi picture alert ~ comparison of Huawei ECs and Alibaba cloud ECS
Appium automation test foundation - appium installation (I)
flink sql 命令行 连接 yarn
Explain kubernetes network model in detail
陈天奇的机器学习编译课(免费)
Resttemplate remote call tool class
Slope compensation
Pytorch nn.functional.unfold()的简单理解与用法
JVM有哪些类加载机制?