Jump to content

Multi-base primes: Difference between revisions

m
→‎{{header|REXX}}: added the number of bases found for any maximums.
(→‎{{header|REXX}}: added the computer programming language REXX.)
m (→‎{{header|REXX}}: added the number of bases found for any maximums.)
Line 905:
30271 => [8 10 12 13 16 17 18 20 21 23 24 25 31 32 33 34 35 36]</pre>
 
=={{header|REXXtREXX}}==
<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= 4 /*Not specified? Then use the default.*/
call genP /*build array of semaphores for primes.*/
namenames= 'one two three four five six seven eight' /*names for some low decimal numbers. */
$.=
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 /*obtainIs the length; Lenth too big?: Then skip Skipit.*/
if L==1 then $.L.n= b $.L.n /*Length = unity? Prepend the base.*/
else $.L.n= $.L.n b /* " ¬= " Append " " */
Line 925:
if y>cnt then do; mxn=n; cnt= max(cnt, y); end /*found a max? Remember it*/
end /*n*/
say
say; say
say; say center(' 'word(namenames, w)'"─character numbers that are" prime in the most bases: ',,
'prime in the most bases: ('cnt "bases) ", 101, "─")
do n=bot to top; y= words($.w.n) /*search again for maxes. */
if y==cnt then say n '──►' strip($.w.n) /*display ───a─── maximum.*/
Line 953:
{{out|output|text=&nbsp; when using the default input:}}
<pre>
────────────────────────────────────── one─character numbers that are prime in the most bases: ──────────────────────(34 bases) ─────────────────
2 ──► 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
 
 
────────────────────────────────────── two─character numbers that are prime in the most bases: ──────────────────────(18 bases) ─────────────────
21 ──► 3 5 6 8 9 11 14 15 18 20 21 23 26 29 30 33 35 36
 
 
──────────────────────────────────── three─character numbers that are prime in the most bases: ─────────────────────(18 bases) ────────────────
131 ──► 4 5 7 8 9 10 12 14 15 18 19 20 23 25 27 29 30 34
551 ──► 6 7 11 13 14 15 16 17 19 21 22 24 25 26 30 32 35 36
Line 967:
 
 
───────────────────────────────────── four─character numbers that are prime in the most bases: ──────────────────────(19 bases) ────────────────
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
Cookies help us deliver our services. By using our services, you agree to our use of cookies.