Bert, > findprm <- function(n){ > nn <- seq.int(2, n) > i <- 2 > while(i <= floor(sqrt( n))){ > nn <- nn[(nn <= i) | (nn %% i > 0)] > i <- nn[nn > i][1] > } > nn > } +1 -- thanks!