The Fibonacci series is computed as follows: Write the R function fibo(n) using a for loop (without any recursion) that
Posted: Sun May 15, 2022 10:07 am
The Fibonacci series is computed as follows:
Write the R function fibo(n) using a for loop
(without any recursion) that returns the first n
numbers in the Fibonacci series.
The function returns a vector with the first n
fibonacci numbers.
Test the function with the following values and provide the
resulting outputs along with the R code.
> fibo(10)
Expected output:
[1] 0 1 1 2 3 5 8 13 21 34
> fibo(13)
Expected output:
[1] 0 1 1 2 3 5 8 13 21 34 55 89 144
Write the R function fibo(n) using a for loop
(without any recursion) that returns the first n
numbers in the Fibonacci series.
The function returns a vector with the first n
fibonacci numbers.
Test the function with the following values and provide the
resulting outputs along with the R code.
> fibo(10)
Expected output:
[1] 0 1 1 2 3 5 8 13 21 34
> fibo(13)
Expected output:
[1] 0 1 1 2 3 5 8 13 21 34 55 89 144