当前位置:网站首页>[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));
}
}
边栏推荐
- Talk about what parameters ZABBIX monitors
- MySQL5.7 设置密码策略(等保三级密码改造)
- Chen Tianqi's machine learning compilation course (free)
- 每日刷题记录 (十)
- flink sql 命令行 连接 yarn
- Using securecrtportable to remotely connect virtual machines
- YOLOv5.5 调用本地摄像头
- 功能测试报告的编写
- 友善串口助手使用教程_友善串口调试助手怎么进行配置-友善串口调试助手使用教程…
- Lc669. Prune binary search tree
猜你喜欢

Clean up system cache and free memory under Linux

C#/VB. Net to add text / image watermarks to PDF documents

详解Kubernetes网络模型

Slope compensation

Pytorch sharpening chapter | argmax and argmin functions

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

2020-ViT ICLR

Appium automated testing foundation - Supplement: introduction to desired capabilities parameters

# CutefishOS系统~

Appium automation test foundation - appium installation (I)
随机推荐
Measurement of reference loop gain and phase margin
MySQL stored procedure
cvpr2022 human pose estiamtion
There is no signal in HDMI in computer games caused by memory, so it crashes
多图预警~ 华为 ECS 与 阿里云 ECS 对比实战
SAP ui5 application development tutorial 104 - multi select support for SAP ui5 table controls and how to use code to select multiple table row items at a time
[literacy] deep / shallow, local / global features in machine learning image processing
Niuke monthly race - logarithmic sum in groups
小红书Scheme跳转到指定页面
使用 Three.js 实现'雪糕'地球,让地球也凉爽一夏
Cut noodles C language
利用SecureCRTPortable远程连接虚拟机
【日常训练】326. 3 的幂
el-input文本域字数限制,超过显示变红并禁止输入
RestTemplate 远程调用工具类
SAP UI5 应用开发教程之一百零四 - SAP UI5 表格控件的支持复选(Multi-Select)以及如何用代码一次选中多个表格行项目
MySQL的视图练习题
【无标题】
447-哔哩哔哩面经1
C#/VB. Net to add text / image watermarks to PDF documents