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

Line 947:
Base 27: 1011f11e37objj² = 1023458elomdhbijfgkp7cq9n6a in 461.305s
Base 28: 58a3ckp3n4cqd7² = 1023456cgjbirqedhp98kmoan7fl in 911.059s
</pre>
 
=={{header|J}}==
<lang>
pandigital=: [ = [: # [: ~. #.inv NB. BASE pandigital Y
</lang>
<pre>
assert 10 pandigital 1234567890
assert -. 10 pandigital 123456789
 
[BASES=: 2+i.11
2 3 4 5 6 7 8 9 10 11 12
 
A=: BASES pandigital&>/ *: i. 1000000 NB. A is a Boolean array marking all pandigital squares in bases 2--12 of 0--999999 squared
 
+/"1 A NB. tally of them per base
999998 999298 976852 856925 607519 324450 114943 33757 4866 416 3
 
] SOLUTION=: A (i."1) 1 NB. but we need only the first
2 8 15 73 195 561 1764 7814 32043 177565 944493
 
representation=: (Num_j_ , 26 }. Alpha_j_) {~ #.inv NB. BASE representation INTEGER
 
BASES ([ ; representation)&> *: SOLUTION
+--+------------+
| 2| 100|
+--+------------+
| 3| 2101|
+--+------------+
| 4| 3201|
+--+------------+
| 5| 132304|
+--+------------+
| 6| 452013|
+--+------------+
| 7| 2450361|
+--+------------+
| 8| 13675420|
+--+------------+
| 9| 136802574|
+--+------------+
|10| 1026753849|
+--+------------+
|11| 1240a536789|
+--+------------+
|12|124a7b538609|
+--+------------+
</pre>
 
Anonymous user