<jupyter_start><jupyter_text>We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.What is the largest n-digit pandigital prime that exists?<jupyter_code>let limit = 99999

let panOneNine = string(123456789)

let isPandigital n = 
    let n_sorted = new string (string(n).ToCharArray() |> Array.sort)
    n_sorted = panOneNine.[0..((n_sorted.Length)-1)]

let divisors n = 
    let div_limit = (1 + (int(sqrt(double(n)))))
    [2..div_limit]
    |> List.filter (fun x -> n % x = 0)    

let isPrimeNaive n = 
    divisors n
    |> List.length = 0

seq { 1..123456789 }
|> Seq.filter isPandigital
|> Seq.filter isPrimeNaive
|> Seq.last<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11498708010335917, 'fraction_numerical': 0.046511627906976744, 'mean_word_length': 3.613095238095238, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '533268', 'license': 'MIT', 'n_tokens_mistral': 323, 'n_tokens_neox': 283, 'n_words': 85, 'path': 'Problem 041 - Pandigital prime.ipynb', 'repo_name': 'smcl/ProjectEulerJupyter', 'size': '774'}