Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #' Sum values with n = n + 1 in difference
- recursive <- function(x){
- if(x==1){
- return(1)
- } else {
- x + recursive(x-1)
- }
- }
- recursive <- Vectorize(recursive)
- recursive(1:100)
- #' Factorial function
- factorial_this <- function(x){
- if(x==1){
- return(1)
- } else {
- x * factorial_this(x-1)
- }
- }
- factorial_this(10)
- factorial(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement