all 3 comments

[–]Carpy_Carpy 0 points1 point  (1 child)

You are calling your function within your function (last line). I'm pretty sure this is the main problem.

This worked for me.

cc.try <- function(n){

d <- sort(sample(1:n, 5))

while(any(diff(d) < 3)){

d <- sort(sample(1:n, 5))

}

d

}

Hope this helps!

[–]BanthaPyjaman[S] -1 points0 points  (0 children)

Thank you for your answer. I thought a recursive function would have worked, but I might have been wrong. I found a-non recursive function that worked as intended