# Create samples from all the permutations
# factorial(16) = 20922789888000, 14 digits
(randomnumber=as.numeric(paste(replicate(14,sample(0:9,1)),collapse="")))
randomnumber=randomnumber
randomnumber=rep(NA,14)
randomnumber[1]=c(sample(0:2,1))
randomnumber[2]=ifelse(randomnumber[1]==2,0,sample(0:9,1))
# etc.
# The first digit can only be 0, 1, or 2.
# If the first digit is 0 or 1, the following digits can be anything.
# If the first digit is 2, then second digit can only be 0
# If the third digit is 9, then the following digit cannot be larger than 2.
# etc.
# But it does not matter, since the fack() function just recycles when numbers
# get bigger than factorial(16)
nsims=10
for(j in 1:nsims){output=rep(NA,16);elements=1:16;rownr=as.numeric(paste(replicate(14,sample(0:9,1)),collapse=""))
for(i in 1:16){
{output[i]=elements[((rownr - ((factorial(17-i)) * (rownr%/%factorial(17-i)))) %/% factorial(16-i))+1]
elements=elements[-(((rownr -((factorial(17-i)) * (rownr%/%factorial(17-i)))) %/% factorial(16-i))+1)]}}
{if(!is.null(exclude(output))) print(output)}}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.