Loop to traverse over all prime P which divide summation
for ( $ i = 2 ; $ i <= sqrt ( $ sumsquares ) ; $ i ++ ) { $ flag = 0 ; while ( $ sumsquares % $ i == 0 ) { $ flag = 1 ; $ countprime ++ ; $ sumsquares = ( int ) ( $ sumsquares / $ i ) ; } if ( $ flag == 1 ) { if ( checkfact ( $ N - 1 , $ countprime , $ i ) ) return false ; $ countprime = 0 ; } }