Module: ScraperUtils::MathsUtils
- Defined in:
- lib/scraper_utils/maths_utils.rb
Overview
Misc Maths Utilities
Class Method Summary collapse
-
.fibonacci_series(max) ⇒ Array<Integer>
Generate a fibonacci series.
Class Method Details
.fibonacci_series(max) ⇒ Array<Integer>
Generate a fibonacci series
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/scraper_utils/maths_utils.rb', line 11 def self.fibonacci_series(max) result = [] # Start with the basic Fibonacci sequence last_fib, this_fib = 1, 0 while this_fib <= max result << this_fib yield this_fib if block_given? last_fib, this_fib = this_fib, this_fib + last_fib end result end |