Prime Factors Only
In this exercise, an “ugly” number is not a bad number — it is a number with a special set of prime factors. Given a number n, return True if it is positive and all of its prime factors are only 2, 3, and 5. The number 1 also counts as valid.
Примеры
Ввод
6Вывод
TrueВвод
1Вывод
TrueВвод
14Вывод
FalseНужно реализовать
def is_ugly(n: int) -> bool:
Теги
math
Melde dich an, um den Einreichungsverlauf zu sehen
AnmeldenMelde dich an, um den KI-Mentor zu nutzen
AnmeldenVisible tests
1
Input
6Expected
True2
Input
1Expected
True3
Input
14Expected
False4
Input
8Expected
True5
Input
0Expected
False6
Input
7Expected
FalseFocus radio
Paused · SomaFM · Fluid