Skip to content

Instantly share code, notes, and snippets.

@kek
Created April 13, 2012 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kek/2377257 to your computer and use it in GitHub Desktop.
Save kek/2377257 to your computer and use it in GitHub Desktop.
\ 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