Find the Nth Mosaic number | Function to return the nth mosaic number ; Iterate from 2 to the number ; If i is the factor of n ; Find the count where i ^ count is a factor of n ; Divide the number by i ; Increase the count ; Multiply the answer with count and i ; Return the answer ; Driver code
def mosaic ( n ) : NEW_LINE INDENT i = 0 NEW_LINE ans = 1 NEW_LINE for i in range ( 2 , n + 1 ) : NEW_LINE INDENT if ( n % i == 0 and n > 0 ) : NEW_LINE INDENT count = 0 NEW_LINE while ( n % i == 0 ) : NEW_LINE INDENT n //= i NEW_LINE count += 1 NEW_LINE DEDENT ans *= count * i NEW_LINE DEDENT DEDENT return ans NEW_LINE DEDENT n = 36 NEW_LINE print ( mosaic ( n ) ) NEW_LINE