The TransCompilator

Solved LeetCode program · 216 of 1,000

#0264 · Ugly Number II

Medium Math chunk-05.md

Original English source

Keep a shared ugly of 0.

To test from value (a whole number). If value is 1, set ugly to 1, return. If value modulo 2 is 0, test from value divided by 2, return. If value modulo 3 is 0, test from value divided by 3, return. If value modulo 5 is 0, test from value divided by 5, return.

The want is 10. The count is 0. The candidate is 0.
Repeat while count is less than want.
Add 1 to candidate. Set ugly to 0. Test from candidate. If ugly is 1, add 1 to count.

Show candidate.

Open in Playground Browse all 1,000 problems

Expected stdout

12