Find the highest power ( stored in exp ) of allPrimes [ i ] that divides n using Legendre 's formula.
$ exp = 0 ; while ( $ p <= $ n ) { $ exp = $ exp + ( int ) ( $ n / $ p ) ; $ p = $ p * $ allPrimes [ $ i ] ; }