FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Architecture & Design
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
January 01, 2001

Programming in Ruby

(Page 6 of 11)
Jan01: Programming in Ruby


def fibUpTo(max)
  n1, n2 = 1, 1
  while n1 <= max
    yield n1              # invoke block value
    n1, n2 = n2, n1+n2    # and calculate next
  end
end

Example 5: Iterator for Fibonacci numbers.

Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 Next Page
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK