当前位置:网站首页>Daily question - ugly number
Daily question - ugly number
2022-07-03 04:05:00 【々 orange if ℃ №】
Learning goals :
A daily topic - Ugly number
source : Power button (LeetCode)
link :https://leetcode-cn.com/problems/ugly-number
Copyright belongs to the network . For commercial reprint, please contact the official authority , Non-commercial reprint please indicate the source .
Learning content :
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 .

solution :
class Solution:
def isUgly(self, n: int) -> bool:
if n<= 0:
return False
for item in [2,3,5]:
while n % item == 0:
n//=item
return n == 1

边栏推荐
- How to execute a swift for in loop in one step- How can I do a Swift for-in loop with a step?
- SAP UI5 应用开发教程之一百零五 - SAP UI5 Master-Detail 布局模式的联动效果实现明细介绍
- Dynamic programming: longest common substring and longest common subsequence
- 2022 polymerization process examination questions and polymerization process examination skills
- JS native common knowledge
- Message queue addition failure
- [daily question] dichotomy - find a single dog (Bushi)
- [mathematical logic] predicate logic (toe normal form | toe normal form conversion method | basic equivalence of predicate logic | name changing rules | predicate logic reasoning law)
- 2.14 simulation summary
- Arlo's thinking about himself
猜你喜欢

How to download pytorch? Where can I download pytorch?

pytorch开源吗?

JS实现图片懒加载

Recursion: quick sort, merge sort and heap sort

NPM: the 'NPM' item cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Please check the spelling of the name. If the path is included, make sure the path is corr

Appium automated testing framework

2022 P cylinder filling examination content and P cylinder filling practice examination video

Supervised pre training! Another exploration of text generation!

Nodejs Foundation: shallow chat URL and querystring module

深潜Kotlin协程(十九):Flow 概述
随机推荐
Filter
Recursive use and multi-dimensional array object to one-dimensional array object
The longest subarray length with a positive product of 1567 recorded by leecode
Read a paper_ ChineseBert
eth入门之简介
leetcode:297. 二叉树的序列化与反序列化
[DRM] simple analysis of DRM bridge driver call process
How does the pytorch project run?
Separable bonds and convertible bonds
【毕业季·进击的技术er】职场人的自白
[Blue Bridge Road -- bug free code] DS18B20 temperature reading code analysis
"Designer universe" argument: Data Optimization in the design field is finally reflected in cost, safety and health | chinabrand.com org
Ffmpeg download and installation tutorial and introduction
错误 C2694 “void Logger::log(nvinfer1::ILogger::Severity,const char *)”: 重写虚函数的限制性异常规范比基类虚成员函数
2022 tea master (primary) examination questions and tea master (primary) examination question bank
以两列的瀑布流为例,我们应该怎么构建每一列的数组
【刷题篇】多数元素(超级水王问题)
Dynamic programming: Longest palindrome substring and subsequence
TCP, the heavyweight guest in tcp/ip model -- Kuige of Shangwen network
300+篇文献!一文详解基于Transformer的多模态学习最新进展