Given an integer N, the task is to find the Nth Mosaic number. A Mosaic number can be expressed as follows:
If N = Aa * Bb * Cc … where A, B, C.. are the prime factors of N then the Nth Mosaic number will be A * a * B * b * C * c ….
Input: N = 8
8 can be expressed as 23.
So, the 8th Mosaic number will be 2 * 3 = 6
Input: N = 36
36 can be expressed as 22 * 32.
2 * 2 * 3 * 2 = 24
Approach: We have to find all the prime factors and also the powers of the factors in the number by dividing the number by the factor until the factor divides the number. The Nth Mosaic number will then be the product of the found prime factors and their powers.
Below is the implementation of the above approach:
- Print first N Mosaic numbers
- Find Nth number in a sequence which is not a multiple of a given number
- Find nth Magic Number
- Program to find last two digits of Nth Fibonacci number
- Find nth Fibonacci number using Golden ratio
- Find nth number that contains the digit k or divisible by k.
- Find Nth even length palindromic number formed using digits X and Y
- Program to find the nth Kynea number
- Find Nth number of the series 1, 6, 15, 28, 45, .....
- Program to find the Nth Harmonic Number
- Program to find the Nth number of the series 2, 10, 24, 44, 70.....
- Find nth Hermite number
- Find Nth positive number whose digital root is X
- Find Nth smallest number that is divisible by 100 exactly K times
- Program to find the Nth Prime Number
- Program to find Nth odd Fibonacci Number
- Find the Nth digit from right in base B of the given number in Decimal base
- Find the Nth Pure number
- Find the Nth natural number which is not divisible by A
- Fast Doubling method to find the Nth Fibonacci number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.