Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Fibonacci
- def self.get_sequence(num)
- if num < 0
- raise ArgumentError.new("Fibonacci sequences must be >= 0")
- elsif num <= 2
- return [1] * num
- end
- seq = get_sequence(num - 1)
- return seq + [ seq[-2] + seq[-1] ]
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement