Untitled
# The smallest three-digit number is 100 and the largest is 999 start = 100 end = 999 # Find the Least Common Multiple (LCM) of 6 and 13 import math def lcm(a, b): return abs(a * b) // math.gcd(a, b) lcm_6_13 = lcm(6, 13) # Find the first and last three-digit numbers divisible by the LCM first = (start + lcm_6_13 - 1) // lcm_6_13 * lcm_6_13 last = end // lcm_6_13 * lcm_6_13 # Calculate the count of numbers divisible by the LCM in the range count = (last - first) // lcm_6_13 + 1 count
Leave a Comment