Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int maxPowerOf(int p, int n)
- {
- int k = 0;
- int powerOfP = 1;
- while (true)
- {
- powerOfP *= p;
- int addend = n / powerOfP;
- if (addend == 0)
- return k;
- k += addend;
- }
- }
- int p3 = maxPowerOf(3, n);
- int p5 = maxPowerOf(5, n);
- int p9 = p3 / 2;
- int p25 = p5 / 2;
- min(p9, p25)
Add Comment
Please, Sign In to add comment