N is now N / s [ N ] . If new N als has smallest prime factor as currFactor , increment power
if ( $ currFactor == $ s [ $ N ] ) { $ power ++ ; continue ; } $ sum = 0 ; for ( $ i = 0 ; $ i <= $ power ; $ i ++ ) $ sum += ( int ) pow ( $ currFactor , $ i ) ; $ ans *= $ sum ;