R program to get the first 10 Fibonacci numbers: A Fibonacci sequence is the integer sequence of
0, 1, 1, 2, 3, 5, 8….
The first two terms are 0 and 1. All other terms are obtained by adding the preceding two terms.
This means to say the nth term is the sum of (n-1)th and (n-2)th term.
R Program To Get the First 10 Fibonacci Numbers
Source Code
Fibonacci <- numeric(10)
Fibonacci[1] <- Fibonacci[2] <- 1
for (i in 3:10) Fibonacci[i] <- Fibonacci[i - 2] + Fibonacci[i - 1]
print("Ten Fibonacci Number = ")
print(Fibonacci)
Output
R program to get the first 10 Fibonacci numbers