I am writing a method that returns the nth element in the Fibonacci sequence, but am running into an unexpected end error.
def fib_seq(n)
a = [0]
n.times do |i|
if i==0
a[i] = 0
else if i==1
a[i] = 1
else
a[i] = a[i-1] + a[i-2]
end
end
return a[n]
end
puts fib_seq(4)
Any tip on what I can be screwing up on?
lowercase_with_underscoresfor method and variables.