login
A389000
Smallest k such that the sums of digits of k and k^2 in base 10 are both divisible by n or a(n) = -1 if no such k exists.
2
1, 2, 3, 13, 19, 24, 149, 583, 9, 19, 74, 264, 2236, 1999, 1374, 19499, 299833, 99, 199, 767, 9417, 812083, 199999, 63087, 1994999, 99483667, 999, 1999, 16697, 768108, 113578114, 19999999, 2424867, 88898999, 69999835714, 9999, 19999, 196967, 38455167, 8943142063
OFFSET
1,2
COMMENTS
Terms are no multiple of 10. - David A. Corneth, Sep 22 2025
From David A. Corneth, Sep 25 2025: (Start)
a(44) <= 94857676958167.
For all k we have digsum(k^2) == digsum(k)^2 (mod 9) (cf. A007953 for digsum).
For n = 44. If digsum(a(44)) = 44 == 8 (mod 9) then digsum(a(44)^2) == digsum(a(44))^2 == 8^2 == 1 (mod 9). The smallest number that is 1 (mod 9) and 0 (mod 44) is 352. then digitsum of k^2 is at least 352 and k^2 has at least ceil(352/9) = 40 digits. But with the upper bound on a(44) that is impossible.
Search can be restricted via last digits of candidate numbers. If a number has m digits then we can define a "loss" of some k with m digits via 9*m - digsum(k). We can than set an upper bound on a loss. For example if a(44) has 14 digits and digsum 88 then the loss is 9*14 - 88 = 38. Similarly if a(44)^2 has 28 digits and digsum 220 then loss is 32. This constrains the search based on last digits.
Does digsum(a(n))/n only depend on n mod 9? In first 43 terms it does. (End)
a(47) = 2897687. a(48) = 1377671187, a(51) = 2754991833. - Chai Wah Wu, Oct 02 2025
a(44) = 94857676958167 (confirmed), a(49) = 2233356191833, a(50) = 199999999999. - Giovanni Resta, Oct 02 2025
LINKS
Chai Wah Wu, Table of n, a(n) for n = 1..52 (see comments for the attribution of terms beyond a(43))
Barney Maunder-Taylor, A New Sequence!
FORMULA
a(9*m) = 10^m - 1. a(9*m + 1) = 2*10^m - 1 for m >= 1. - David A. Corneth, Sep 25 2025
Conjecture: a(9*m+5) = 2*10^(2*m+1)-1 for m >= 0. - Chai Wah Wu, Oct 01 2025
EXAMPLE
For n = 4, a(4) = 13 as 1+3 mod 4 = 0 and 13^2 = 169 and 1+6+9 mod 4 = 0.
PROG
(Haskell) import Data.Char
a n = head [k | k <- [1..], sum (map digitToInt (show k)) `mod` n ==0, sum (map digitToInt (show (k^2))) `mod` n ==0]
list n = [a k | k <- [1..n]]
(Python)
from itertools import count
from collections import Counter
from sympy.utilities.iterables import partitions, multiset_permutations
def A389000(n):
for l in count(n//9+bool(n%9)):
m, c = n, 10**l
while m<=9*l:
for s, p in partitions(m, m=l, k=9, size=True):
p[0] = l-s
for q in multiset_permutations(sorted(Counter(p).elements())):
if q[0]:
k = int(''.join(str(d) for d in q))
if k>=c:
break
if not sum(int(d) for d in str(k**2))%n:
c = min(c, k)
break
m += n
if c<10**l: return c # Chai Wah Wu, Sep 22 2025
CROSSREFS
Sequence in context: A338216 A143871 A225517 * A254462 A275030 A194598
KEYWORD
nonn,base
AUTHOR
EXTENSIONS
a(35) onwards from Chai Wah Wu, Sep 22 2025
STATUS
approved