Multi-base primes: Difference between revisions

m
up to base 62
(→‎{{header|Wren}}: Generalized program to deal with any base up to 62. Added results for latter.)
m (up to base 62)
Line 466:
441431 => [5, 8, 9, 11, 12, 14, 16, 17, 19, 21, 22, 23, 26, 28, 30, 31, 32, 33]
4.808196 seconds (8.58 M allocations: 357.983 MiB, 0.75% gc time)
</pre>
 
== Up to base 62 ==
<lang julia>using Primes
 
function maxprimebases(ndig, maxbase)
maxprimebases = [Int[]]
nwithbases = ["0"]
for tup in Iterators.product([0:maxbase-1 for _ in 1:ndig - 1]..., 1:maxbase-1)
dig = collect(tup)
foundbases = Int[]
for b in maximum(dig)+1:maxbase
if isprime(evalpoly(b, dig))
push!(foundbases, b)
end
maxbase - b + length(foundbases) < length(maxprimebases) && break # shortcut if hopeless
end
if length(foundbases) > length(first(maxprimebases))
maxprimebases = [foundbases]
nwithbases = [prod(string.(reverse(dig), base = any(x -> x > 9, dig) ? 32 : 10))]
elseif length(foundbases) == length(first(maxprimebases))
push!(maxprimebases, foundbases)
push!(nwithbases, prod(string.(reverse(dig), base = any(x -> x > 9, dig) ? 32 : 10)))
end
end
alen, vlen = length(first(maxprimebases)), length(maxprimebases)
println("\nThe maximum number of prime valued bases for base up to $maxbase numeric strings of length ",
ndig, " is $alen. The value list of ", vlen > 1 ? "these" : "this", " is:")
for i in eachindex(maxprimebases)
println(nwithbases[i], maxprimebases[i][1] > 10 ? "(base 32)" : "", " => ", maxprimebases[i])
end
end
 
for n in 1:4
maxprimebases(n, 36)
maxprimebases(n, 62)
end
</lang>{{out}}
<pre>
The maximum number of prime valued bases for base up to 36 numeric strings of length 1 is 34. The value list of this is:
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]
 
The maximum number of prime valued bases for base up to 62 numeric strings of length 1 is 60. The value list of this is:
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, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62]
 
The maximum number of prime valued bases for base up to 36 numeric strings of length 2 is 18. The value list of this is:
21 => [3, 5, 6, 8, 9, 11, 14, 15, 18, 20, 21, 23, 26, 29, 30, 33, 35, 36]
 
The maximum number of prime valued bases for base up to 62 numeric strings of length 2 is 31. The value list of this is:
65 => [7, 8, 9, 11, 13, 14, 16, 17, 18, 21, 22, 24, 27, 28, 29, 31, 32, 37, 38, 39, 41, 42, 43, 44, 46, 48, 51, 52, 57, 58, 59]
 
The maximum number of prime valued bases for base up to 36 numeric strings of length 3 is 18. The value list of these is:
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]
737 => [8, 9, 11, 12, 13, 15, 16, 17, 19, 22, 23, 24, 25, 26, 29, 30, 31, 36]
 
The maximum number of prime valued bases for base up to 62 numeric strings of length 3 is 33. The value list of these is:
1l1(base 32) => [22, 23, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 51, 52, 53, 54, 57, 58, 59, 60, 61, 62]
b9b(base 32) => [13, 14, 15, 16, 17, 19, 20, 21, 23, 24, 26, 27, 28, 30, 31, 34, 36, 39, 40, 42, 45, 47, 49, 50, 52, 53, 54, 57, 58, 59, 60, 61, 62]
 
The maximum number of prime valued bases for base up to 36 numeric strings of length 4 is 19. The value list of these is:
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]
 
The maximum number of prime valued bases for base up to 62 numeric strings of length 4 is 32. The value list of these is:
1727 => [8, 9, 11, 12, 13, 15, 16, 17, 19, 20, 22, 23, 24, 26, 27, 29, 31, 33, 36, 37, 38, 39, 41, 45, 46, 48, 50, 51, 57, 58, 60, 61]
417b(base 32) => [12, 13, 15, 16, 17, 18, 19, 21, 23, 25, 28, 30, 32, 34, 35, 37, 38, 39, 41, 45, 48, 49, 50, 51, 52, 54, 56, 57, 58, 59, 61, 62]
</pre>
 
4,102

edits