1 Star 0 Fork 0

footmanff / leetcode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
P263.java 635 Bytes
一键复制 编辑 原始数据 按行查看 历史
footmanff 提交于 2020-08-12 13:45 . 263
package com.footmanff.leetcode;
/**
* https://leetcode-cn.com/problems/ugly-number/
*
* @author footmanff on 2020/8/11.
*/
public class P263 {
/**
* 暴力
*/
public boolean isUgly(int num) {
if (num < 1) {
return false;
}
while (num % 2 == 0) {
num = num / 2;
}
while (num % 3 == 0) {
num = num / 3;
}
while (num % 5 == 0) {
num = num / 5;
}
return num == 1;
}
public static void main(String[] args) {
int n = 30;
System.out.println(new P263().isUgly(n));
}
}
Java
1
https://gitee.com/footmanff/leetcode.git
git@gitee.com:footmanff/leetcode.git
footmanff
leetcode
leetcode
master

搜索帮助