Back
Close
  • 87

Statement

 Goal

Given two integers A and B, you have to find the largest power of A that divides B! with no remainder.
You have to find the largest integer value of X such that A^X divides B! where B! = B × (B-1) × (B-2) × … × 2 × 1.
Input
One line containing A and B, separated by a single space.
Output
A single line containing X, the largest power of A that divides B!
Constraints
2 ≤ A, B ≤ 10^7
Example
Input
7 14
Output
2
Solve it

A higher resolution is required to access the IDE

codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants