You are on page 1of 1

Practice Problem

Ugly Numbers
(Input File: practice.txt)

Write a program to find and print the N'th ugly number.

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, 14, ... shows the first 11 ugly numbers. By convention, 1 is
included.

Input
The input file is made of R test cases. The input file starts with an integer R with specifies the
number of test cases. Following the integer R there are R lines, each containing an integer N.

Output
For each test case your program should print the N’th ugly number.

Sample Input
3
4
11
100

Sample Output
4
11
135

You might also like