# ruby problem of bonacci series

code can be also found on this link https://code.sololearn.com/cva9U4w84M39/#rb #bonacci series 0 0 0 0 1 1 2 4 8... class Array_basic def bonacci(n,m) arr = Array.new y = n-1 #here is problem if y = n-2 given for i in 0..y #n... creates problem y = n-2 is also has problem arr[i] = 0 end arr << 1 #arr[3] = 1 #or use following #arr <<1 for j in 1...m-n arr[n+j] = 0 arr.values_at[n+j] #or it doest not work #arr[4..9] = 0 or arr[j] = 0 for k in 1...n # puts "-- #{arr[n+j]} --- #{arr[n+j-k]}" arr[n+j] = arr[n+j] + arr[n+j-k] end end puts "-- >#{arr}" end end obje = Array_basic.new puts "Input n and m. n must smaller then m" n = gets.to_i m= gets.to_i #bonacci series implemention call obje.bonacci(n,m) =begin problem: on line 4 if y = n-1 given it is fully functional. if y = n-2 given then it says following on Console--- `+': nil can't be coerced into Integer (TypeError) can anyone look that program where the actually problem is? =end