Link Search Menu Expand Document

Fibonacci

Generate Fibonacci series.

def generate_fibonacci(n) {
  var fib = [1] * n
  for i in 2..n {
    fib[i] = fib[i - 2] + fib[i - 1]
  }
  return fib
}

var fib = generate_fibonacci(35)
print(' '.join(fib))

Back to top

Copyright © 2021 Ore Richard Muyiwa. Distributed under the MIT license.