Trains the technique from
LeetCode 204Count PrimesThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A parts depot gives every stock item a whole-number catalogue code. The stocktaking team calls a code indivisible when the code is 2 or larger and no whole number other than 1 and the code itself divides it exactly.
A clerk is auditing the codes below a cut-off limit. Report how many indivisible codes are smaller than limit. Codes equal to limit are outside the audit window and must not be counted, and when limit is so small that the window holds nothing, the tally is 0.
Example 1
The indivisible codes under the cut-off are 2, 3, 5, 7, 11, 13, 17, 19 and 23, so the clerk records nine of them.
Example 2
Only the code 2 sits under the cut-off. The code 3 equals the cut-off, so it stays out of the window.
Example 3
Twenty-four codes below 97 have no divisor other than 1 and themselves; 97 itself is indivisible but is excluded by the cut-off.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def count_indivisible_codes(limit: int) -> int:public int countIndivisibleCodes(int limit)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.