{"id":"5ff7e222-f6d6-40a0-892f-4d4ace1f9de6","name":"Ugly Number","description":"1. You are given a number N.\r\n2. You have to find Nth ugly number.\r\n3. Ugly number is defined as the number whose prime factors are only 2,3 and 5. \r\n4. First eleven ugly numbers are -> 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15.\r\n\r\nAssumption -> 1 is the first ugly number.","inputFormat":"A number N","outputFormat":"A number representing Nth ugly number.","constraints":"1 <= N <= 10^4","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static int solution(int n) {\r\n // write your code here\r\n\r\n return 0;\r\n }\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n System.out.println(solution(n));\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"4","sampleOutput":"4\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"6d4b494a-ee6a-4d62-a348-14712ed7fe2d","name":"Ugly Number","slug":"ugly-number","type":1}],"next":{"id":"afb0eb13-c38b-450a-95db-aacb6c12329f","name":"Super Ugly Number","type":1,"slug":"super-ugly-number"},"prev":{"id":"8f1010b0-00ab-4a0d-9ecf-e10eba378292","name":"Min Max Value Expression","type":1,"slug":"min-max-value-expression"}}}

Ugly Number

1. You are given a number N. 2. You have to find Nth ugly number. 3. Ugly number is defined as the number whose prime factors are only 2,3 and 5. 4. First eleven ugly numbers are -> 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15. Assumption -> 1 is the first ugly number.

{"id":"5ff7e222-f6d6-40a0-892f-4d4ace1f9de6","name":"Ugly Number","description":"1. You are given a number N.\r\n2. You have to find Nth ugly number.\r\n3. Ugly number is defined as the number whose prime factors are only 2,3 and 5. \r\n4. First eleven ugly numbers are -> 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15.\r\n\r\nAssumption -> 1 is the first ugly number.","inputFormat":"A number N","outputFormat":"A number representing Nth ugly number.","constraints":"1 <= N <= 10^4","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static int solution(int n) {\r\n // write your code here\r\n\r\n return 0;\r\n }\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n int n = scn.nextInt();\r\n System.out.println(solution(n));\r\n }\r\n\r\n}"},"ruby":{"code":""},"python":{"code":""},"javascript":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"4","sampleOutput":"4\r\n","questionVideo":"","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"6d4b494a-ee6a-4d62-a348-14712ed7fe2d","name":"Ugly Number","slug":"ugly-number","type":1}],"next":{"id":"afb0eb13-c38b-450a-95db-aacb6c12329f","name":"Super Ugly Number","type":1,"slug":"super-ugly-number"},"prev":{"id":"8f1010b0-00ab-4a0d-9ecf-e10eba378292","name":"Min Max Value Expression","type":1,"slug":"min-max-value-expression"}}}
plane

Editor


Loading...

Ugly Number

medium

1. You are given a number N. 2. You have to find Nth ugly number. 3. Ugly number is defined as the number whose prime factors are only 2,3 and 5. 4. First eleven ugly numbers are -> 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15. Assumption -> 1 is the first ugly number.

Constraints

1 <= N <= 10^4

Format

Input

A number N

Output

A number representing Nth ugly number.

Example

Sample Input

4

Sample Output

4

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode