Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2,3,5.

**Input:** n= 10 **Output:** 12

Explanation: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers.

Note: 1 is typically treated as an ugly number.

n= int(input('')) list=[] count=0 i=1 while count<n: temp=i while(temp%2==0): temp=temp/2 while(temp%3==0): temp=temp/3 while(temp%5==0): temp=temp/5 if temp==1: list.append(i) count+=1 i+=1 #print(list) print(list[n-1]) # list values starts from index value 0

Input_1: Enter the nth value : 7

Output : The last value in the list that is nth ugly value = 8

Input_2: Enter the nth value : 10

Output : The last value in the list that is nth ugly value = 12

Input_3: Enter the nth value : 15

Output : The last value in the list that is nth ugly value = 24

Input_4: Enter the nth value : 1

Output : The last value in the list that is nth ugly value = 1

Input_5: Enter the nth value : 200

Output : The last value in the list that is nth ugly value = 16200

DEMO Output

**More Q**

- Find the majority element appearing more than n/2 times
- Return an array of the squares of each number.
- Highest factor in addition.
- Find the empty packets(0) of chocolate and push it to the end of the conveyor belt(array).
- Every element in array appears twice.Find that single one.
- Find the duplicate letters in string. Same to do in dictionary way.
- Find minimum number of edits (operations) required to convert ‘str1’ into ‘str2’.
- Return the maximum number you can get by changing at most one digit.
- Sed Commands – Ranges of lines.
- Find the kth smallest element in the given 2D array.
- Find all elements that appear more than [n/3] times.
- Write a function to return true if s2 contains the permutation of s1.
- Sort the array into a wave like array.
- Re-order array, such that
`nums[0] < nums[1] > nums[2] < nums[3]...`

. - Given the coordinates, return true if the four points construct a square.
- Minimum Distance Between Words of a String.
- Return the shortest distance between these two words.
- Write a program to find the n-th ugly number.
- Check if array could become Non – Decreasing array.
- Find the minimum area of a rectangle that can be formed from given points.