# R, 30

###code

    f=function(N)cat(runif(1)<1/N)

It generates a number from a uniform distribution (0 to 1) and should evaluate to true 1/n of the times.