Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

IF ELSE function in R studio

$
0
0

Can somebody explain why this code results in 1 for input: exam(5)?

exam<-function(x){
  y<-1
  if(x==1){
    return(1)
  }
  else{
    return(y*exam(x-1))
    y<-y+1
  }
}

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>