Penholodigital squares: Difference between revisions

m
Line 457:
There is a total of 740 penholodigital squares in base 16:
11156eb6² = 123da7f85bce964 3fd8f786² = fec81b69573da24
</pre>
=== Extended version ===
Theoretically, the program should be able to handle bases up to 30, but in practice that would take it far too long.
<syntaxhighlight lang=="Julia">function penholodigital(base)
penholodigitals = [typeof(base)[] for _ in 1:Threads.nthreads()]
digitbuf = [zeros(typeof(base), base-1) for _ in 1:Threads.nthreads()]
hi, lo = isqrt(evalpoly(base, 1:base-1)), isqrt(evalpoly(base, base-1:-1:1))
@Threads.threads for n in lo:hi
dig = digitbuf[Threads.threadid()]
digits!(dig, n * n; base)
0 in dig && continue
if all(i -> count(==(i), dig) == 1, 1:base-1)
push!(penholodigitals[Threads.threadid()], n * n)
end
end
return sort!(vcat(penholodigitals...))
end
 
for j in 9:19
@time begin
allpen = penholodigital(j < 17 ? j : Int128(j))
println("There are a total of $(length(allpen)) penholodigital squares in base $j:")
if length(allpen) > 0
for (i, n) in (j < 14 ? enumerate(allpen) : enumerate([allpen[begin], allpen[end]]))
print(string(isqrt(n), base=j), "² = ", string(n, base=j), i %3 == 0 ? "\n" : " ")
end
end
end
println("\n")
end
</syntaxhighlight>{{out}}
<pre>
There are a total of 10 penholodigital squares in base 9:
3825² = 16328547 3847² = 16523874 4617² = 23875614
4761² = 25487631 6561² = 47865231 6574² = 48162537
6844² = 53184267 7285² = 58624317 7821² = 68573241
8554² = 82314657 0.180057 seconds (213.67 k allocations: 10.895 MiB, 98.16% compilation time)
 
 
There are a total of 30 penholodigital squares in base 10:
11826² = 139854276 12363² = 152843769 12543² = 157326849
14676² = 215384976 15681² = 245893761 15963² = 254817369
18072² = 326597184 19023² = 361874529 19377² = 375468129
19569² = 382945761 19629² = 385297641 20316² = 412739856
22887² = 523814769 23019² = 529874361 23178² = 537219684
23439² = 549386721 24237² = 587432169 24276² = 589324176
24441² = 597362481 24807² = 615387249 25059² = 627953481
25572² = 653927184 25941² = 672935481 26409² = 697435281
26733² = 714653289 27129² = 735982641 27273² = 743816529
29034² = 842973156 29106² = 847159236 30384² = 923187456
0.008105 seconds (770 allocations: 28.117 KiB)
 
 
There are a total of 20 penholodigital squares in base 11:
42045² = 165742a893 43152² = 173a652894 44926² = 18792a6453
47149² = 1a67395824 47257² = 1a76392485 52071² = 249a758631
54457² = 2719634a85 55979² = 286a795314 59597² = 314672a895
632a4² = 3671a89245 64069² = 376198a254 68335² = 41697528a3
71485² = 46928a7153 81196² = 5a79286413 83608² = 632a741859
86074² = 6713498a25 89468² = 7148563a29 91429² = 76315982a4
93319² = 795186a234 a3a39² = 983251a764 0.008614 seconds (538 allocations: 21.164 KiB)
 
 
There are a total of 23 penholodigital squares in base 12:
117789² = 135b7482a69 16357b² = 23a5b976481 16762b² = 24ab5379861
16906b² = 25386749ba1 173434² = 26b859a3714 178278² = 2835ba17694
1a1993² = 34a8125b769 1a3595² = 354a279b681 1b0451² = 3824b7569a1
1b7545² = 3a5b2487961 2084a9² = 42a1583b769 235273² = 5287ba13469
2528b5² = 5b23a879641 25b564² = 62937b5a814 262174² = 63a8527b194
285a44² = 73b615a8294 29a977² = 7b9284a5361 2a7617² = 83ab5479261
2b0144² = 8617b35a294 307381² = 93825a67b41 310828² = 96528ab7314
319488² = 9ab65823714 319a37² = 9b2573468a1 0.021154 seconds (606 allocations: 23.141 KiB)
 
 
There are a total of 0 penholodigital squares in base 13:
0.093971 seconds (67 allocations: 6.148 KiB)
 
 
There are a total of 160 penholodigital squares in base 14:
1129535² = 126a84d79c53b 3a03226² = db3962a7541c8 0.678507 seconds (148 allocations: 12.523 KiB, 0.55% compilation time)
 
 
There are a total of 419 penholodigital squares in base 15:
4240c58² = 12378da5b6ec94 ee25e4a² = ed4c93285671ba 4.194926 seconds (137 allocations: 22.289 KiB)
 
 
There are a total of 740 penholodigital squares in base 16:
11156eb6² = 123da7f85bce964 3fd8f786² = fec81b69573da24 10.843582 seconds (137 allocations: 24.789 KiB)
 
 
There are a total of 0 penholodigital squares in base 17:
345.116100 seconds (335.36 k allocations: 17.403 MiB, 0.08% compilation time)
 
 
There are a total of 5116 penholodigital squares in base 18:
11150fc0g² = 123cd8abh5g79f6e4 44422dd18² = hgef25738d496bc1a 2584.183274 seconds (332.23 k allocations: 17.565 MiB, 0.00% gc time, 0.01% compilation time)
 
 
There are a total of 47677 penholodigital squares in base 19:
4b802235a² = 1234978cibd6gfhea5 ii844bia2² = ihg8f71c6da59be324 20734.916185 seconds (169 allocations:
2.163 MiB)
</pre>
 
4,102

edits