Talk:First perfect square in base n with n unique digits: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (→analytically determine minimum start value: A few more small, mostly cosmetic fixes) |
|||
Line 298: | Line 298: | ||
So, at a minimum, the smallest starting value will need an extra 6 |
So, at a minimum, the smallest starting value will need an extra 6 |
||
Minimum start value: 10234566789ABCDEFGHIJK</pre> |
Minimum start value: 10234566789ABCDEFGHIJK</pre> |
||
==Calculating quadratic residues== |
|||
The valid digital roots can be calculated using the following code in F#: |
|||
<lang Fsharp> |
|||
let rSet g=set[for n in [0..g-1] do yield n*n%g] |
|||
</lang> |
|||
rSet 20 -> set [0; 1; 4; 5; 9; 16]. Remember that this is base 20 and 0 corresponds to 20.<br>Similar code in Python is: |
|||
<lang Python> |
|||
rSet=lambda g: {n*n%g for n in range(1,g)} |
|||
</lang> |
|||
rSet(20) -> {0, 1, 4, 5, 9, 16}<br>--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 17:02, 25 May 2019 (UTC) |