Skip to content

Instantly share code, notes, and snippets.

@kozross
Created April 1, 2016 10:30
Show Gist options
  • Save kozross/3ccc2496eb35f08b348706484fe88f02 to your computer and use it in GitHub Desktop.
Save kozross/3ccc2496eb35f08b348706484fe88f02 to your computer and use it in GitHub Desktop.
4000000 constant LIMIT
\ n -- f
: is-even? 2 mod 0= ;
\ w1 w2 w3 -- w2 w1 w3
: flip rot swap ;
\ total prev curr -- total+ curr next
: add-even-and-gen dup is-even?
if flip dup under+ flip
then dup under+ swap ;
: do-the-needful begin 0 1 2 add-even-and-gen dup LIMIT > until rot ;
do-the-needful .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment