1, 4, 9, 36, 81, 100, 121, … , 225, … represent squares such that the sum of digits of each of them is also a square number.
From 81 to 225 there are seven consecutive squares.
Where about is another run of consecutive 7?
Maybe 8 or more?
What is the present “state of art”?
How far could you explore ?
The next stretch of 7 is:
[99980001, 100000000, 100020001, 100040004, 100060009, 100080016, 100100025]
The first stretch of 8 is:
[2120219933855716, 2120220025947409, 2120220118039104, 2120220210130801, 2120220302222500, 2120220394314201, 2120220486405904, 2120220578497609]
When I ran from 1 up to 100,000,000 (not including zero), but recording more than one instance only for stretches more the 6 in length, I got:
3 [1, 4, 9]
1 [36]
7 [81, 100, 121, 144, 169, 196, 225]
4 [400, 441, 484, 529]
2 [900, 961]
6 [10000, 10201, 10404, 10609, 10816, 11025]
7 [99980001, 100000000, 100020001, 100040004, 100060009, 100080016, 100100025]
5 [123409881, 123432100, 123454321, 123476544, 123498769]
8 [2120219933855716, 2120220025947409, 2120220118039104, 2120220210130801, 2120220302222500, 2120220394314201, 2120220486405904, 2120220578497609]
I was initially checking the sod() values against a large list of squares, but the program ran about 150 times faster if I checked only against a very short list of squares, since the sod could be at most 9 times the number of digits of the square.
---------
def sod(n):
""" Input an integer. Returns the Sum of the Digits """
aList = list(str(n))
ans = 0
for c in aList:
ans = ans + int(c)
return ans
big = 100000000
top = 2 + int((9*len(str(big**2)))**.5)
sod_searchs = [i*i for i in range(1,top)]
squares = []
myDictionary = {}
top = 2 + int((9*len(str(big**2)))**.5)
sod_searchs = [i*i for i in range(1,top)]
squares = []
myDictionary = {}
first_one = 0
in_a_row = 0
for i in range(1,big):
s = i*i
squares.append(s)
if sod(s) in sod_searchs:
if in_a_row == 0:
first_one = i
in_a_row += 1
else:
if in_a_row > 0:
this_run = i - first_one
if this_run not in myDictionary:
myDictionary[this_run] = [j*j for j in range(first_one, i)]
print(this_run,[j*j for j in range(first_one, i)])
elif this_run in myDictionary and this_run > 6:
myDictionary[this_run] = [myDictionary[this_run]].append( [j*j for j in range(first_one, i)] )
print(this_run,[j*j for j in range(first_one, i)])
in_a_row = 0
|
Posted by Larry
on 2023-04-30 12:48:54 |