当前位置:网站首页>leetcode 263. Ugly number
leetcode 263. Ugly number
2022-06-12 04:29:00 【kt1776133839】
Title Description :
Give you an integer n , Please judge n Is it Ugly number . If it is , return true ; otherwise , return false .
Ugly number That is, only the prime factor is included 2、3 and / or 5 The positive integer .
Examples :
Example 1:
Input :n = 6
Output :true
explain :6 = 2 × 3
Example 2:
Input :n = 8
Output :true
explain :8 = 2 × 2 × 2
Example 3:
Input :n = 14
Output :false
explain :14 It's not ugly , Because it contains another prime factor 7 .
Example 4:
Input :n = 1
Output :true
explain :1 It's usually considered ugly .
Tips :
-2^31 <= n <= 2^31 - 1
Java Program :
class Solution {
public boolean isUgly(int n) {
if (n <= 0) {
return false;
}
int[] factors = {2, 3, 5};
for (int factor : factors) {
while (n % factor == 0) {
n /= factor;
}
}
return n == 1;
}
}边栏推荐
- Work report of epidemic data analysis platform [1] data collection
- Plot visualization in R language: visualize the scatter diagram of the actual value and the predicted value of the regression model, analyze the prediction efficiency of the regression model, distingu
- Zabbix6.0 new feature GEOMAP map marker can you use it?
- Kill session? This cross domain authentication solution is really elegant!
- MySQL master-slave construction and Django implementation of read-write separation
- [FPGA chaos] implementation of FPGA based chaotic system Verilog
- JSP implementation of bank counter business performance evaluation system
- From science to startup
- Zabbix6.0新功能Geomap 地图标记 你会用吗?
- [Clickhouse column] user initialization of new library role
猜你喜欢

Create a new table in the database. There was no problem before. Today

E-commerce middle office system architecture

Based on Visual Studio code Net Maui cross platform mobile application development
![[wechat applet] the mobile terminal selects and publishes pictures](/img/9a/46bc4a7bf9b70d26b0e24fe02f747d.jpg)
[wechat applet] the mobile terminal selects and publishes pictures

D1 Nezha development board power on record

DS18B20数字温度计 (一) 电气特性, 供电和接线方式

【C语言】变量本质分析

Smart panel WiFi linkage technology, esp32 wireless chip module, Internet of things WiFi communication application

How to use union all in LINQ- How to use union all in LINQ?

如何制作数据集并基于yolov5训练成模型并部署
随机推荐
Work report of epidemic data analysis platform [6] visual drawing
How to make datasets, train them into models and deploy them based on yolov5
Oracle's instr()
Esp32c3 remote serial port
【FPGA+GPS接收器】基于FPGA的双频GPS接收器详细设计介绍
Detailed explanation of software testing process
windows如何安装多个版本mysql,如何同时启动
[fpga+fft] design and implementation of FFT frequency meter based on FPGA
Kill session? This cross domain authentication solution is really elegant!
Manually encapsulate a foreacht and map
[software tool] [original] tutorial on using VOC dataset class alias batch modification tool
PHP and JS remove all spaces
分布式锁介绍
[wechat applet] the mobile terminal selects and publishes pictures
[issue 31] 360 background development practice experience - two rounds of technical aspects
动规(15)-最低通行费
Introduction to distributed locks
Work report of epidemic data analysis platform [6.5] epidemic map
WPF data binding (IV)
Recommended system cleaning tools, cocktail Download