Extremely Ugly

Extremely Ugly

The mission is in Blocked Mode. Access to the solutions is blocked for a day or two (even after you share your own), until we'll have enough solutions for you to check. All users who've solved the mission will get the notifications about their opening.

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... shows the first 11 ugly numbers. By convention, 1 is included. Write a program to find and print the N’th ugly number. Same as previous task with a minor difference - input value limit is 1000000, and output is str.

ugly_numbers

Input: N, int.

Output: N'th Ugly Number, str.

Example:

extremely_ugly(4) == '4'
extremely_ugly(6) == '6'
extremely_ugly(11) == '15'
extremely_ugly(999) == '51018336'

How it’s used: Demonstrate that straight way can be very slow

Precondition: Given int is below or equal of 1000000

Idea for the mission was taken from ICPC challenge