Multi-base primes: Difference between revisions

m
→‎{{header|REXX}}: upgraded REXX program to solve for five-character numbers that are prime in the most bases.
m (→‎{{header|Pascal}}: check count of primes in base enpassant no need for big array BaseCnvCount (10 Mbyte for 6 digits ))
m (→‎{{header|REXX}}: upgraded REXX program to solve for five-character numbers that are prime in the most bases.)
Line 901:
<lang rexx>/*REXX pgm finds primes whose values in other bases (2──►36) have the most diff. bases. */
parse arg widths . /*obtain optional argument from the CL.*/
if widths=='' | widths=="," then widths= 45 /*Not specified? Then use the default.*/
call genP /*build array of semaphores for primes.*/
names= 'one two three four five six seven eight' /*names for some low decimal numbers. */
Line 907:
do j=1 for # /*only use primes that are within range*/
do b=36 by -1 for 35; n= base(@.j, b) /*use different bases for each prime. */
L= length(n); if L>widths then iterate /*Is theobtain length; Lenth too big: Then? skip itSkip.*/
if L==1 then $.L.n= b $.L.n /*Length = unity? Prepend the base.*/
else $.L.n= $.L.n b /* " ¬= " Append " " */
Line 935:
genP: @.1=2; @.2=3; @.3=5; @.4=7; @.5=11 /*define some low primes. */
#=5; s.#= @.# **2 /*number of primes so far; prime². */
do j=@.#+2 by 2 to 2 * 36 * 10**widths /*find odd primes from here on. */
parse var j '' -1 _; if _==5 then iterate /*J divisible by 5? (right dig)*/
if j// 3==0 then iterate /*" " " 3? */
Line 963:
1727 ──► 8 9 11 12 13 15 16 17 19 20 22 23 24 26 27 29 31 33 36
5347 ──► 8 9 10 11 12 13 16 18 19 22 24 25 26 30 31 32 33 34 36
 
 
──────────────── five─character numbers that are prime in the most bases: (18 bases) ────────────────
30271 ──► 8 10 12 13 16 17 18 20 21 23 24 25 31 32 33 34 35 36
</pre>