Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Ugly Number
Bookmark
Input
Simple Ugly
Power of 2
Not Ugly
One
All Factors
Custom
n
=
6
allowed factors
2
3
5
n =
6
Ugly numbers factor into only 2, 3, and 5
allowed factors
2
3
5
n =
6
Ugly numbers factor into only 2, 3, and 5
allowed factors
2
3
5
n =
6
n = 6 > 0
allowed factors
2
3
5
factor
n =
6
try factor
2
allowed factors
2
3
5
factor
6 =
2
3
×
3
not divisible by 2
allowed factors
2
3
5
factor
6 =
2
3
×
try factor
3
allowed factors
2
3
5
factor
6 =
2
3
1
×
×
3 ÷ 3 =
1
allowed factors
2
3
5
factor
6 =
2
3
1
×
×
1
not divisible by 3
allowed factors
2
3
5
factor
6 =
2
3
1
×
×
1
not divisible by 5
allowed factors
2
3
5
6 =
2
3
×
n = 1 → only 2, 3, 5 as factors
allowed factors
2
3
5
6 =
2
3
×
n = 1 → only 2, 3, 5 as factors
6 is ugly
algo
master
.
io
Step:
Start: is n = 6 an ugly number?
0 / 11
Input
Simple Ugly
Power of 2
Not Ugly
One
All Factors
Custom
n
=
6
0 / 11
algo
master
.
io
Step:
Start: is n = 6 an ugly number?