Created
April 13, 2012 14:27
-
-
Save kek/2377257 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\ 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? | |
: divisible-by-upto? { n upto -- bool } | |
0 | |
upto 1+ 1 ?do | |
n i mod + | |
dup 0 <> if leave endif | |
loop | |
0 = | |
; | |
: problem5 | |
0 | |
begin | |
1+ | |
dup 20 divisible-by-upto? | |
until | |
; | |
problem5 . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment