Product of factors of number | Java program to calculate product of factors of number ; function to product the factors ; If factors are equal , multiply only once ; Otherwise multiply both ; Driver Code
class GFG { public static final long M = 1000000007 ; static long multiplyFactors ( int n ) { long prod = 1 ; for ( int i = 1 ; i * i <= n ; i ++ ) { if ( n % i == 0 ) { if ( n / i == i ) prod = ( prod * i ) % M ; else { prod = ( prod * i ) % M ; prod = ( prod * n / i ) % M ; } } } return prod ; } public static void main ( String [ ] args ) { int n = 12 ; System . out . println ( multiplyFactors ( n ) ) ; } }