Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 270c760

Browse files
ybian19azl397985856
authored andcommitted
feat: 263.ugly-number add Python3 implementation (azl397985856#141)
1 parent 6e18ef5 commit 270c760

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

‎problems/263.ugly-number.md‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Explanation: 8 = 2 ×ばつ 2 ×ばつ 2
2222
Example 3:
2323
2424
Input: 14
25-
Output: false
25+
Output: false
2626
Explanation: 14 is not ugly since it includes another prime factor 7.
2727
Note:
2828
@@ -61,10 +61,14 @@ Input is within the 32-bit signed integer range: [−231, 231 − 1].
6161
## 关键点
6262
- 数论
6363
- 因数分解
64+
6465
## 代码
6566

66-
```js
67+
* 语言支持:JS, Python
68+
69+
Javascript Code:
6770

71+
```js
6872
/*
6973
* @lc app=leetcode id=263 lang=javascript
7074
*
@@ -90,3 +94,16 @@ var isUgly = function(num) {
9094
};
9195
```
9296

97+
Python Code:
98+
99+
```python
100+
# 非递归写法
101+
class Solution:
102+
def isUgly(self, num: int) -> bool:
103+
if num <= 0:
104+
return False
105+
for i in (2, 3, 5):
106+
while num % i == 0:
107+
num /= i
108+
return num == 1
109+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /