fibonacci <- function(n) {
  fib_sequence <- numeric(n)  
  fib_sequence[1] <- 0       
  fib_sequence[2] <- 1        
  
  for (i in 3:n) {
    fib_sequence[i] <- fib_sequence[i - 1] + fib_sequence[i - 2]  
  }
  
  return(fib_sequence)
}
first_10_fib <- fibonacci(10)
print(first_10_fib)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: