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 minimum number to be divided to make a number a perfect square
- Given number of matches played, find number of teams in tournament
- Find the number of positive integers less than or equal to N that have an odd number of digits
- Find the maximum number of composite summands of a number
- Find the number of ways to divide number into four parts such that a = c and b = d
- Find count of digits in a number that divide the number
- Find the total number of composite factor for a given number
- Find the number of integers x in range (1,N) for which x and x+1 have same number of divisors
- Find the smallest number whose digits multiply to a given number n
- Find the number of jumps to reach X in the number line from zero
- Find the largest good number in the divisors of given number N
- Find maximum number that can be formed using digits of a given number
- Find if a number is divisible by every number in a list
- Find M-th number whose repeated sum of digits of a number is N
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.