How to resolve the algorithm First perfect square in base n with n unique digits step by step in the Quackery programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm First perfect square in base n with n unique digits step by step in the Quackery programming language
Table of Contents
Problem Statement
Find the first perfect square in a given base N that has at least N digits and exactly N significant unique digits when expressed in base N. E.G. In base 10, the first perfect square with at least 10 unique digits is 1026753849 (32043²). You may use analytical methods to reduce the search space, but the code must do a search. Do not use magic numbers or just feed the code the answer to verify it is correct.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm First perfect square in base n with n unique digits step by step in the Quackery programming language
Source code in the quackery programming language
[ dup 1
[ 2dup > while
+ 1 >>
2dup / again ]
drop nip ] is sqrt ( n --> n )
[ base share bit 1 -
0 rot
[ dup while
base share /mod bit
rot | swap again ]
drop = ] is pandigital ( n --> b )
[ base share
dup 2 - times
[ base share *
i^ 2 + + ] ] is firstpan ( --> n )
[ dup * ] is squared ( n --> n )
11 times
[ i^ 2 + base put
firstpan sqrt from
[ index squared
pandigital if
[ index end ] ]
base share
say "Base " decimal echo
base release
say ": " dup echo
say "^" 2 echo say " = "
squared echo
cr base release ]
You may also check:How to resolve the algorithm Even or odd step by step in the ColdFusion programming language
You may also check:How to resolve the algorithm Find limit of recursion step by step in the PowerShell programming language
You may also check:How to resolve the algorithm Window creation step by step in the NetRexx programming language
You may also check:How to resolve the algorithm Fractal tree step by step in the POV-Ray programming language
You may also check:How to resolve the algorithm Sorting algorithms/Stooge sort step by step in the Julia programming language