Skip to content

Commit

Permalink
Create 0263-ugly-number.py
Browse files Browse the repository at this point in the history
Code transcribed from the video https://www.youtube.com/watch?v=M0Zay1Qr9ws
  • Loading branch information
AP-Repositories authored Dec 30, 2022
1 parent 2d0e0cc commit 58c8b79
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions python/0263-ugly-number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Solution:
def isUgly(self, n: int) -> bool:
if n <= 0:
return False

for p in [2, 3, 5]:
while n % p == 0:
n = n // p
return n == 1

0 comments on commit 58c8b79

Please sign in to comment.