Favourite Numbers

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Problem type

Out of all the numbers that exist, justinzhu only likes some specific numbers. The only numbers that he like are numbers, if prime factorized, only contain the numbers 2 or 3. However, since justinzhu really likes to be number 1 (even though that never happens), the smallest number that he likes is the number 1.

Out of all these numbers, justinzhu would like for you to write a solution that finds the N^{th} smallest number that he likes.

Note that your answer may exceed a 32-bit integer.

Input Specification

One Integer N (1 \leq N \leq 1000), the N^{th} number that he is looking for.

Output Specification

One Value, the N^{th} smallest number in the list of numbers that justinzhu likes.

Sample Input 1


Sample Output 1


Explanation for Sample Output 1

The first 5 numbers that justinzhu likes are 1, 2, 3, 4, 6. Thus, the 5th one is 6, the one he is looking for.

Sample Input 2


Sample Output 2


Explanation for Sample Output 2

The next 3 numbers are 8, 9, 12, so 12 is the answer.

Sample Input 3


Sample Output 3



There are no comments at the moment.