Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 662 |

@arpitsatnalika | 629 |

@code_it_ | 591 |

@prakharxyz | 583 |

@tujhekya | 542 |

@Rahul Jadhav 1 | 458 |

@sivanandh03 | 448 |

@satyam0460 | 433 |

@imnm | 426 |

@iamronak | 424 |

@18eumc107 | 421 |

Complete Leaderboard |

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 **N ^{th}** Ugly Number.

**Example 1:**

**Input:
**N = 10
**Output: **12
**Explanation:** 10_{th} ugly number is 12.

**Example 2:**

**Input:
**N = 4
**Output:** 4
**Explanation: **4_{th} ugly number is 4.

**Your Task:**

You don't need to read input or print anything. Your task is to complete the function **getNthUglyNo()** which takes an integer **n**** **as parameters and returns an integer denoting the answer.

**Expected Time Complexity:** O(N)

**Expected Auxiliary Space:** O(N)

**Constraints:**

1 ≤ N ≤ 10^{4}

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Ugly Numbers

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.