Posted By

cmm7825 on 05/20/10


Tagged


Versions (?)

Problem 2


 / Published in: Ruby
 

  1. #!/usr/bin/ruby
  2.  
  3. sum = 0
  4. vals = [0,1]
  5. while(vals.last <= 4000000) do
  6. vals.push(vals[-1] + vals[-2])
  7. if(vals.last % 2 == 0)
  8. sum += vals[-1]
  9. end
  10. end
  11.  
  12. puts sum

Report this snippet  

You need to login to post a comment.