1 1 practice503 Asked: January 20, 20222022-01-20T13:40:02+05:30 2022-01-20T13:40:02+05:30In: Data Science Write RScript to create a recursive function to implement Fibonacci series. 1 1 Write RScript to create a recursive function to implement Fibonacci series. data science using r Share Facebook 1 Answer Voted Oldest Recent I'M ADMIN 2022-01-22T23:18:29+05:30Added an answer on January 22, 2022 at 11:18 pm recurse_fib <- function(n) { if(n <= 1) { return(n) } else { return(recurse_fib(n-1) + recurse_fib(n-2)) } } #type number of terms: nterms =10 # check if the number of terms is valid if(nterms <= 0) { print("Plese enter a positive integer") } else { print("Fibonacci sequence:") for(i in 0:(nterms-1)) { print(recurse_fib(i)) } } Leave an answerCancel replyYou must login to add an answer. Username or email* Password* Remember Me! Forgot Password?
1 Answer