Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*execute with: $ scala name_of_file.scala*/
- def ProjectEuler1(limit:Long) = {
- def rec(sum:Long , limit:Long , cur:Long):Long = {
- if (limit==cur) sum
- else if ( cur%3==0 || cur%5 == 0) rec(sum+cur,limit,cur+1)
- else rec(sum,limit,cur+1)
- }
- rec(0,limit,1)
- }
- println(ProjectEuler1(1000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement