Euler problem 41

Project Euler is a pretty good way to exercise your programming muscles. I tend to think that the hardest part is usually the math.

So when I figure one of them out in minutes, I’m pretty happy about it.

library(gtools)
library(numbers)
pandig <- function(n){
x <- permutations(n,n)
x <- apply(x,1, function(x) paste(x, collapse=""))
return(x)
}
y <- as.numeric(pandig(7))
max(y[isPrime(y)])

The surprising thing is that largest pandigital prime does not begin with either 8 or 9.