Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- # The problem: 2520 is the smallest number that can be divided by each
- # of the numbers from 1 to 10 without any remainder. What is the
- # smallest positive number that is evenly divisible by all of the
- # numbers from 1 to 20?
- # Since non-prime numbers in the range of 11 through 20 are all
- # divisible by a number in the range of 2 through 10, only numbers in
- # the former range are checked for being factors. Thus, the product of
- # these numbers should be the maximum checked value.
- product = 1
- for i in range(11,21):
- product *= i
- # Since the biggest factor is 20 and the check starts with 20, the
- # step should also be 20.
- checked = 20
- while checked <= product:
- for i in range(20,10,-1):
- if checked % i != 0:
- break
- else:
- print(checked)
- break
- checked += 20
- # 232792560
Add Comment
Please, Sign In to add comment