OFFSET
0,1
COMMENTS
3|a(n).
LINKS
EXAMPLE
a(2)=3114 because 3114 is the least 4-digit integer whose square has digit sum 9*(4+2) = 9*6 = 54: 3114^2 = 9696996 and 9+6+9+6+9+9+6 = 54.
MATHEMATICA
n=0; For[k=0, k<10^8/3, k++, If[Total[IntegerDigits[9k^2]]==9*(n+Ceiling@Log10@(3k)), Print[{n, 3k}]; n++]]
PROG
(Python)
def sd(n):
return sum(int(d) for d in str(n*n))
n=0
for k in range(0, 10**8, 3):
if sd(k)==9*(len(str(k))+n):
print([n, k])
n+=1
(PARI) a(n) = my(m=1); while (sumdigits(m^2) != 9*(#Str(m)+n), m++); m; \\ Michel Marcus, Feb 10 2024
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Zhining Yang, Feb 06 2024
EXTENSIONS
a(9)-a(18) from Zhao Hui Du, Feb 19 2024
STATUS
approved