Find largest left truncatable prime in a given base: Difference between revisions

m (→‎{{header|Fortran}}: Using a big base for arithmetic.)
(→‎{{header|Fortran}}: Deviationism.)
Line 578:
 
Going further will require MANY to be enlarged. Already, base twelve required just over nineteen thousand entries, and base eighteen overflowed MANY = 66666. This suggests that a lot of data is being shifted about, so some sort of linked-list scheme might reduce that. Incidentally, in <code>B.LAST = A.LAST; B.DIGIT(1:N) = A.DIGIT(1:N)</code> and similar, because the storage for .DIGIT immediately follows that for .LAST, one might hope that an advanced compiler would combine the two statements into one sequential copy... Alas, the Compaq F90/95 compiler produces two wads of code, of 20 operations and then 92. Bounds checking is active, but still...
 
And, as one who can recall when one was admitted to the status of "prime" (like, being divisible only by itself and one), what about allowing numbers to end with the digit one...
<pre>
Working in bases 3 to 17 there are 1 single-digit primes: 1
 
Base Digits Count Maximum Value = (in base)
3 2 1 7 = 2.1
4 7 1 9829 = 2.1.2.1.2.1.1
5 4 1 311 = 2.2.2.1
6 19 1 580639005096133 = 5.4.1.4.5.2.5.5.1.3.1.5.5.1.3.1.4.2.1
7 8 1 3602999 = 4.2.4.2.4.2.4.1
8 9 1 104056657 = 6.1.4.7.4.3.5.2.1
9 5 3 41023 = 6.2.2.4.1
10 20 1 89726156799336363541 = 8.9.7.2.6.1.5.6.7.9.9.3.3.6.3.6.3.5.4.1
11 7 1 11750399 = 6.6.10.6.2.8.1
12 30 1 57434208867139354150297607357437 = 2.10.10.1.1.11.6.4.4.7.11.8.2.2.8.10.8.7.6.5.9.5.2.2.10.2.1.5.9.1
13 10 1 66073331221 = 6.2.12.12.10.8.12.10.12.1
14 25 1 39607537776359469390989456509 = 12.4.7.3.5.12.3.11.6.3.11.5.11.9.13.9.3.7.10.12.6.4.3.8.1
15 20 4 319674182915416424428051 = 14.6.4.8.6.8.12.6.2.4.10.8.6.4.8.14.14.14.10.1
16 23 2 2208955789035921681292672241 = 7.2.3.3.4.9.5.4.5.1.5.7.8.15.9.3.3.4.3.3.12.15.1
17 11 2 16408729108033 = 8.2.6.4.4.6.14.2.12.6.1
 
The MR prime test makes a series of trials, stopping early
only when a "definitely composite" result is encountered.
Trial: 1 2 3 4 5 6
Count: 97667 44905 44904 44904 44904 44904
CPU time: 111.2656
</pre>
 
=={{header|Haskell}}==
1,220

edits