Generate and show all primes with strictly ascending decimal digits.

Aside: Try solving without peeking at existing solutions. I had a weird idea for generating
a prime sieve faster, which needless to say didn't pan out. The solution may be p(r)etty trivial
but generating them quickly is at least mildly interesting.
Tip: filtering all 7,027,260 primes below 123,456,789 probably won't kill you, but there is
at least one significantly better and much faster way, needing a mere 511 odd/prime tests.



See also
 OEIS:A052015 - Primes with distinct digits in ascending order


Related

Primes with digits in nondecreasing order (infinite series allowing duplicate digits, whereas this isn't and doesn't)
Pandigital prime (whereas this is the smallest, with gaps in the used digits being permitted)


local function is_prime(n)
  if n < 2 then return false end
  if n % 2 == 0 then return n==2 end
  if n % 3 == 0 then return n==3 end
  for f = 5, n^0.5, 6 do
    if n%f==0 or n%(f+2)==0 then return false end
  end
  return true
end
 
local function ascending_primes()
  local digits, candidates, primes = {1,2,3,4,5,6,7,8,9}, {0}, {}
  for i = 1, #digits do
    for j = 1, #candidates do
      local value = candidates[j] * 10 + digits[i]
      if is_prime(value) then primes[#primes+1] = value end
      candidates[#candidates+1] = value
    end
  end
  table.sort(primes)
  return primes
end
 
print(table.concat(ascending_primes(), ", "))