Find largest left truncatable prime in a given base: Difference between revisions
Find largest left truncatable prime in a given base (view source)
Revision as of 08:46, 4 April 2017
, 7 years ago→{{header|Fortran}}
(→{{header|Fortran}}: Multi-digit arithmetic...) |
|||
Line 413:
</lang>
As checked via earlier tests, using a fixed value for BIGLIMIT that is "surely big enough" enables faster execution
INTEGER F !I/O unit number.
TYPE(BIGNUM) B !The number.
Line 442:
END FUNCTION BIGISPRIME !Can't be bothered with ISPRIME from PRIMEBAG.
</lang>
Which is to say that BIGWRITE will show the digits of a number as decimal numbers separated by periods rather than involving letters as additional digit symbols, while BIGTEN will prepare a text version in base ten, whatever BIGBASE is. Finally, BIGMRPRIME
IF (N.LAST.LE.2) THEN !A smallish number? I want to compare to four, but BIGBASE might be two.
NR = BIGVALUE(N) !Surely so.
Line 547:
</lang>
And the results, slightly edited to remove a few columns of spaces...
<pre>
Working in bases 3 to 17 there are 7 single-digit primes: 2, 3, 5, 7, 11, 13, 17
Base Digits Count
3 3 1
4 6 3
5 6 1
6 17 1
7 7 1
8 15 1
9 10 3
10 24 1
11 9 1
12 32 1
13 8 4
14 26 2
15 22 1
16 25 1
17 11 1
The MR prime test makes a series of trials, stopping early
|