Talk:First perfect square in base n with n unique digits: Difference between revisions

Content added Content deleted
(→‎analytically determine minimum start value: Argh. pasted in wrong version. fixed)
m (→‎analytically determine minimum start value: A few more small, mostly cosmetic fixes)
Line 190: Line 190:
Note: I would not have figured this out without the above analysis by Hout and Nigel Galloway. Kudos to both of them.
Note: I would not have figured this out without the above analysis by Hout and Nigel Galloway. Kudos to both of them.


Here is a Perl 6 script showing each step spelled out: [https://tio.run/##fVNNb9owGL7zK56iaARGoqaTWg1UOk277LDTtNNYKwfegKfEzuxkLULpj9p1t/4xZsdJIFRaDsQ47/s@H36ck0qvDwddxljzDS9YGigpC/he/eIaK5nvpph5MdM0xn4A87iPt@4drmQWhxnL/f3s3bXvPYyrcajLLLQdftP3uOUptfVbpjQWiObHYWFu9ig4aZkPqsHA8kq40kWgf5VMEfzPooAnWiKa7TCajPCEm/fzbmf40QwwVQgCfNOkUWwJudSax4ZErVPPhsf6bIcPumDKSkpSVmAUjaYYXZof/wpheG8RX/42goShdoRaik/ON9SeyMSASd2hYDitaw2EM81AnBrtw7/vDw9/Si6M4e1//AdOOzxyHlnFosxiMu5ygdiZcC7U9d3Cj4wwi2dPbvLyp17MsO/T8x46Yj1OqPqsvnDBszIzzUlCisSKLLW9J6qgnufcSZTMIAW9or3uiVo0yWqpW/NkkmiyB5Rx4TsR4UaRYTzp6g2twK0acrniNi5db7taWMy7O1zi4qLdPD9dnpyUXzZ56xQD/r5GetsUVS30EWa8FEvxVU5hEsUsb@vQtBauM5amZLTXseNig98sLQmPPE0hiNZgAvRUKNYOa6ywj8vq96iF/nGi7Pn1V9dYgVKThzMZjiGEbMBcaqG3skzXiMlwWZHWTO3ChkB1cuztobu7UyuwgW8o1EE2ZpqO8E3vEidSIboxFwtX0fxw@Ac Try it online!]
Here is a Perl 6 script showing each step spelled out: [https://tio.run/##fVNNb9owGL7zK56iaARGrNJJrQYqnaZddthp2mmslQNvwFNiZ3ayFqH0R@26W/8Ys@MECJWWAzHO@77Phx/npNPr/d6UMVZiLQqeRlqpAmFQv4TBUuXbMaZBzA0NsevBPv7jrX@zpcpilvE83E3fXYfBw7AaMlNmzHWETd/jRqTU1m@4NphjMjsOY7ndo@ikZdarej3HKxHaFJH5VXJNCD/LAoFsiRi@xWA0wBNu3s8OO/2PdoCtQhThmyGDYkPIlTEitiRqnWbaP9ZnW3wwBddOUpLyAoPJYIzBpf0Jr8DYvUN8@dsIkpbaEWohP3nfUHuiEgumzAEF/XFdayG8aRbi1OgQ4X13OPuphLSGt//xHzjj8ch75BTLMovJuiskYm/CuVDfd2uVMebg3MGNXv7Uiyl2XXbBw4FXhxKqLqkvQoqszGxzkpAmuSTHbBfIKqrneXMSrTIoSa9Yrzqa5t6qlrizTiWJIXc8mZChl8DWmizhEeZNDi2ryK8abrkWLiyH3nY1d5B3d7jExUW7eX62Ijkpv2zSdhAMhLsa6W1TVLXQR5jhQi7kVzWGzRN3vJ1B41q3yXiakpVeh07INX7ztCQ8ijSFJFqBS9BToXk7rLHCPT6p3yct9I8TZc@vv/rGCpTaNJzJ8AwhVQPmMwuzUWW6QkyWy5KM4XrLGgLVyam3Z@5vTq3Axb2hUMfYmmk72JvOFU6UxuTGXitcTWb7/T8 Try it online!]


<pre>sub digital-root ($root is copy, :$base) {
<pre>sub digital-root ($root is copy, :$base) {
Line 206: Line 206:


say "\nDigital roots of the first $n numbers in base $n:";
say "\nDigital roots of the first $n numbers in base $n:";
say my @roots = (2..$n).map(*²).map: { digital-root($_.base($n), :base($n) ) };
say my @roots = (1..^$n).map(*²).map: { digital-root($_.base($n), :base($n) ) };


say "\nMinimum difference of {$n}-digit root from one of the first $n digital roots > $root:";
say "\nMinimum difference of {$n}-digit root from one of the first $n digital roots >= $root:";
my $offset = min(@roots.grep: * >= $root ) - $root;
my $offset = min(@roots.grep: * >= $root ) - $root;


Line 235: Line 235:


Digital roots of the first 17 numbers in base 17:
Digital roots of the first 17 numbers in base 17:
[4 9 16 9 4 1 16 1 4 9 16 9 4 1 16 1]
[1 4 9 16 9 4 1 16 1 4 9 16 9 4 1 16]


Minimum difference of 17-digit root from one of the first 17 digital roots > 8:
Minimum difference of 17-digit root from one of the first 17 digital roots >= 8:
1 (9 - 8 = 1)
1 (9 - 8 = 1)


Line 249: Line 249:


Digital roots of the first 18 numbers in base 18:
Digital roots of the first 18 numbers in base 18:
[4 9 16 8 2 15 13 13 15 2 8 16 9 4 1 17 1]
[1 4 9 16 8 2 15 13 13 15 2 8 16 9 4 1 17]


Minimum difference of 18-digit root from one of the first 18 digital roots > 17:
Minimum difference of 18-digit root from one of the first 18 digital roots >= 17:
0
0


Line 263: Line 263:


Digital roots of the first 19 numbers in base 19:
Digital roots of the first 19 numbers in base 19:
[4 9 16 7 18 13 10 9 10 13 18 7 16 9 4 1 18 1]
[1 4 9 16 7 18 13 10 9 10 13 18 7 16 9 4 1 18]


Minimum difference of 19-digit root from one of the first 19 digital roots > 9:
Minimum difference of 19-digit root from one of the first 19 digital roots >= 9:
0
0


Line 277: Line 277:


Digital roots of the first 20 numbers in base 20:
Digital roots of the first 20 numbers in base 20:
[4 9 16 6 17 11 7 5 5 7 11 17 6 16 9 4 1 19 1]
[1 4 9 16 6 17 11 7 5 5 7 11 17 6 16 9 4 1 19]


Minimum difference of 20-digit root from one of the first 20 digital roots > 19:
Minimum difference of 20-digit root from one of the first 20 digital roots >= 19:
0
0


Line 291: Line 291:


Digital roots of the first 21 numbers in base 21:
Digital roots of the first 21 numbers in base 21:
[4 9 16 5 16 9 4 1 20 1 4 9 16 5 16 9 4 1 20 1]
[1 4 9 16 5 16 9 4 1 20 1 4 9 16 5 16 9 4 1 20]


Minimum difference of 21-digit root from one of the first 21 digital roots > 10:
Minimum difference of 21-digit root from one of the first 21 digital roots >= 10:
6 (16 - 10 = 6)
6 (16 - 10 = 6)