login
A228915
Next larger integer with same digital sum (that is, sum of digits in base 10) as n.
12
10, 11, 12, 13, 14, 15, 16, 17, 18, 100, 20, 21, 22, 23, 24, 25, 26, 27, 28, 101, 30, 31, 32, 33, 34, 35, 36, 37, 38, 102, 40, 41, 42, 43, 44, 45, 46, 47, 48, 103, 50, 51, 52, 53, 54, 55, 56, 57, 58, 104, 60, 61, 62, 63, 64, 65, 66, 67, 68, 105, 70, 71, 72
OFFSET
1,1
COMMENTS
This is a variant of A057168 for the base 10.
All integers except those in A051885 appear in this sequence.
n+9 <= a(n) <= 10*n, for any n > 0.
a(n)-n is a multiple of 9, for any n > 0.
EXAMPLE
To compute a(n):
(1) Choose the rightmost digit D of n strictly less than 9 and with at least one nonzero digit after it (note that D may be a leading zero),
(2) Increment D,
(3) Replace the digits after D by A051885((sum of the digits after D) - 1), left padded with zeros.
For n = 2930:
(1) We choose the 4th digit,
(2) We increment the 4th digit,
(3) We replace the last 3 digits with "029" (= A051885((9+3+0)-1) left padded with zeros to 3 digits).
Hence, a(2930) = 3029.
MATHEMATICA
nli[n_]:=Module[{k=n+1, s=Total[IntegerDigits[n]]}, While[Total[ IntegerDigits[ k]] !=s, k++]; k]; Array[nli, 70] (* Harvey P. Dale, Sep 27 2016 *)
PROG
(PARI) See Link section.
(PARI) A228915(n, p=1, d, r)={while(8<(d=n%10) || !r, n\=10; r+=d; p*=10); n*p+p+A051885(r-1)} \\ (Based on the above program.) - M. F. Hasler, Mar 15 2022
(Python)
def A228915(n):
p = r = 0
while True:
d = n % 10
if d < 9 and r: return (n+1)*10**p+A051885(r-1)
n //= 10; r += d; p += 1
# (Based on Tek's PARI program.) - M. F. Hasler, Mar 15 2022
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Paul Tek, Sep 08 2013
STATUS
approved