Python Chocolates By Numbers
from math import gcd
def chocolates_by_numbers(n: int, m: int) -> int:
return (n * m) // gcd(n, m) // m
This uses the greatest common divisor to figure out how many chocolates get eaten before the pattern repeats.
from math import gcd
def chocolates_by_numbers(n: int, m: int) -> int:
return (n * m) // gcd(n, m) // m
This uses the greatest common divisor to figure out how many chocolates get eaten before the pattern repeats.