Skip to content

Commit 1cb981b

Browse files
committed
problem 2
1 parent 9dc7a72 commit 1cb981b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

2.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fib = Enumerator.new do |yielder|
2+
i = 1
3+
j = 1
4+
loop do
5+
i, j = j, i + j
6+
yielder.yield i
7+
end
8+
end
9+
p fib.take_while {|n| n < 4E6}.select{|x| x % 2 != 0 }.inject{|sum, x| sum += x}
10+
11+
12+

0 commit comments

Comments
 (0)