PracticeMath

Universal Token Batch Size

EasyMathaccumulationstate trackinginvariants Time not estimated Not started

Context

A document indexing service processes tokens in recurring batches. Its audit reports examine groups of every size from 1 through a configured limit, so a complete audit cycle must contain a number of tokens divisible by each of those group sizes. Determine the shortest positive cycle that satisfies all report schedules.

Problem

Given the largest required group size, return the smallest positive number of tokens that can complete every audit grouping from size 1 through that limit. The answer must be divisible by each integer in the inclusive range from 1 to limit. Since the cycle can grow quickly, compute it without simulating token content or storing batches.

Examples

Example 1
Input: limit = 1
Output: 1
Explanation: For limit 1, the executed call returns 1.
Example 2
Input: limit = 5
Output: 60
Explanation: For limit 5, the executed call returns 60, with candidate equal to 60 at completion.
Example 3
Input: limit = 8
Output: 840
Explanation: For limit 8, the executed call returns 840, with candidate equal to 840 at completion.

Constraints

  • 1 <= limit <= 15
  • Types: limit is int; result is int

Function signature

def find_universal_token_batch_size(limit: int) -> int
limit int
The largest token-group size required by the audit reports.
returns int
The smallest positive token count divisible by every integer from 1 through limit.

Adapted from MBPP problem task_901 (CC BY 4.0). Rewritten, extended and verified by Iksha.

Notes

  • The input is always a positive integer.
  • The inclusive range begins at 1, whose presence does not change the least common multiple.
Approved · cc011-abs_301_v312 execution-verified tests
Code
Saved
Checking environment…Python SandboxLn 1, Col 1