RosettaCodeData/Task/Josephus-problem/R/josephus-problem.r
Ingy döt Net 6f050a029e update
2013-06-05 21:47:54 +00:00

8 lines
153 B
R

jose <-function(s, r,n){
y <- 0:(r-1)
for (i in (r+1):n)
y <- (y + s) %% i
return(y)
}
> jose(3,1,41) # r is the number of remained prisoner.
[1] 30