Math Fundamentals18 sections · 814 units
Open in Course

Ugly Number - Pseudocode

(Implementation ready)

function isUgly(n): if n <= 0: return false

while n % 2 == 0: n = n / 2 while n % 3 == 0: n = n / 3 while n % 5 == 0: n = n / 5

return n == 1