From f5faca69cf91e7fd09660488261435694811447f Mon Sep 17 00:00:00 2001 From: Arshitha B Date: Thu, 12 Dec 2019 11:35:50 -0500 Subject: [PATCH] deleted fibonacci.R --- session_2/R/fibonacci.R | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 session_2/R/fibonacci.R diff --git a/session_2/R/fibonacci.R b/session_2/R/fibonacci.R deleted file mode 100644 index 9f19fa0..0000000 --- a/session_2/R/fibonacci.R +++ /dev/null @@ -1,25 +0,0 @@ -# https://www.datamentor.io/r-programming/examples/fibonacci-recursion/ - -# Program to display the Fibonacci sequence up to n-th term using recursive functions -recurse_fib <- function(n) { - if(n <= 1) { - return(n) - } else { - return(recurse_fib(n-1) + recurse_fib(n-2)) - } -} - -fib_seq <- function() { - # take input from the user - nterms = as.integer(readline(prompt="How many terms? ")) - - # 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)) - } - } -}