Skip to content

Commit 183b02d

Browse files
authored
fib with yield
1 parent cf0c2f0 commit 183b02d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

0 Basics/fibUpTo.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def fibUpTo(max)
2+
i1, i2 = 1, 1
3+
while i1 <= max
4+
yield i1
5+
i1, i2 = i2, i1+i2
6+
end
7+
end
8+
9+
fibUpTo(1000) { |f| print f, " " }

0 commit comments

Comments
 (0)