Function to find distinct prime factors of given number n
< ? php function primeFactors ( $ n ) { $ res = array ( ) ; if ( $ n % 2 == 0 ) { while ( $ n % 2 == 0 ) $ n = ( int ) $ n / 2 ; array_push ( $ res , 2 ) ; }