I am a novice in R, and so what seemed to work fine in C and Python, surprisingly breaks down in R. I am trying to calculate the product of the first 1000 Fibonacci numbers.
Arrays in R are 1-based.
Fibonacci[1]<-1 Fibonacci[2]<-1 Product<-1 for (i in 3:1000) {
(the remainder as in your question)
The problem is Fibonacci[0] which is a 0-length numeric. When i = 2, this expression has a right hand side of numeric(0):
Fibonacci[0]
i = 2
numeric(0)
Fibonacci[i]<-(Fibonacci[i-1])+(Fibonacci[i-2])