Permalink
Browse files

Renomeado + Cabeçalho

  • Loading branch information...
1 parent fa0891e commit 2ac26270897bbd8b3e0400eb6dad004894d119aa @pbalduino committed Mar 7, 2014
Showing with 16 additions and 10 deletions.
  1. +0 −10 002/ruby/euler002.rb
  2. +16 −0 002/ruby/euler002_nicolasfrancax.rb
View
@@ -1,10 +0,0 @@
-# http://projecteuler.net/problem=2
-
-sum, before, now = 0, 1, 1
-
-while now < 4_000_000
- before, now = now, now + before
- sum += now if now % 2 == 0
-end
-
-puts sum
@@ -0,0 +1,16 @@
+# Problem 2 - Even Fibonacci numbers
+
+#Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
+# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
+# By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
+#
+# Source: http://projecteuler.net/problem=2
+
+sum, before, now = 0, 1, 1
+
+while now < 4_000_000
+ before, now = now, now + before
+ sum += now if now % 2 == 0
+end
+
+puts sum

0 comments on commit 2ac2627

Please sign in to comment.