1. Squares of 2 different digits


Let b=a2, b is consisted of 2 different digits.
First I describe the algorithm of counting the digits in b.

Let c$ be the string of b, that is c$=cutlspc(str(b)), and d is the length of b, d=len(c$).
Align z$(10) as the saving array of each digits.
Scaning c$ from rightmost digit and repeat the following procedure.

  1. let f=1
  2. first digit is stored in z$(1)
  3. for second digit and after, compare to z$(1) through z$(f),
  4. when comparing to leftmost digit is complete, terminate the procedure.
    f indicates the amounts of different digits.
    b=a^2 : c$=cutlspc(str(b)) : d=len(c$)
    for i=d to 1 step -1 : f=0 : e$=mid(c$,i,1)
      if f=0 then inc f : z$(f)=e$ : goto *
      for j=1 to f
        if e$=z$(j) then cancel for : goto *
      next j
      inc f : z$(f)=e$
#     if f>2 then cancel for : goto ** : ' greater than 2
*   next i
    print a , b
**  return

Calling above routine from main loop of a, we can get the solutions of the arbitrary range.
The followings are the results of sporadic patterns.

ab=a2
11
12
15
21
22
121
144
225
441
484
26
38
88
109
173
676
1444
7744
11881
29929
212
235
264
3114
81619
44944
55225
69696
9696996
6661661161

Only above 15 solutions are known.
I computed the range b ≤ 1048, but couldn't find the next solution.


Above results are too depressing. So I extended the original problem as,

  1. 3 different digits
  2. perfect n-th power

For "3 different digits", change the "#" line as,

if f>3

and for "perfect n-th power", change the first line as,

b=a^n.


previous index next

E-mail : kc2h-msm@asahi-net.or.jp
Hisanori Mishima