Project Euler : problem 001

Project Euler problems in Oforth . Feel free to post your own code.

Project Euler : problem 001

Postby Franck » 26 Jul 2015 10:33

Problem 1 : Find the sum of all the multiples of 3 or 5 below 1000.

Code: Select all
 
: pe001(n) -- n1 :  Returns sum of all multiples of 3 or 5 below n
| i |
   0 n 1- loop: i [ i 3 mod i 5 mod and ifFalse: [ i + ] ] ;
 
Franck
 
Posts: 159
Joined: 29 Oct 2014 19:01

Return to Project Euler in Oforth

Who is online

Users browsing this forum: No registered users and 1 guest