p041.scm 355 B

12345678910111213
  1. ;; Pandigital primes
  2. (define-module (solved p041))
  3. (use-modules (euler primes)
  4. (euler utils))
  5. ;; Based on 3 divisibility, we can eliminate 8 and 9 digit primes
  6. (define* (largest-n-pandigital-prime #:optional (primes (erato (expt 10 7))))
  7. (let lp ([primes (reverse primes)])
  8. (if (pandigital? (car primes)) (car primes)
  9. (lp (cdr primes)))))