cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A228915 Next larger integer with same digital sum (that is, sum of digits in base 10) as n.

This page as a plain text file.
%I A228915 #27 Mar 18 2022 13:17:10
%S A228915 10,11,12,13,14,15,16,17,18,100,20,21,22,23,24,25,26,27,28,101,30,31,
%T A228915 32,33,34,35,36,37,38,102,40,41,42,43,44,45,46,47,48,103,50,51,52,53,
%U A228915 54,55,56,57,58,104,60,61,62,63,64,65,66,67,68,105,70,71,72
%N A228915 Next larger integer with same digital sum (that is, sum of digits in base 10) as n.
%C A228915 This is a variant of A057168 for the base 10.
%C A228915 All integers except those in A051885 appear in this sequence.
%C A228915 n+9 <= a(n) <= 10*n, for any n > 0.
%C A228915 a(n)-n is a multiple of 9, for any n > 0.
%H A228915 Paul Tek, <a href="/A228915/b228915.txt">Table of n, a(n) for n = 1..10000</a>
%H A228915 Paul Tek, <a href="/A228915/a228915.txt">PARI program for this sequence</a>
%e A228915 To compute a(n):
%e A228915 (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),
%e A228915 (2) Increment D,
%e A228915 (3) Replace the digits after D by A051885((sum of the digits after D) - 1), left padded with zeros.
%e A228915 For n = 2930:
%e A228915 (1) We choose the 4th digit,
%e A228915 (2) We increment the 4th digit,
%e A228915 (3) We replace the last 3 digits with "029" (= A051885((9+3+0)-1) left padded with zeros to 3 digits).
%e A228915 Hence, a(2930) = 3029.
%t A228915 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 *)
%o A228915 (PARI) See Link section.
%o A228915 (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
%o A228915 (Python)
%o A228915 def A228915(n):
%o A228915     p = r = 0
%o A228915     while True:
%o A228915         d = n % 10
%o A228915         if d < 9 and r: return (n+1)*10**p+A051885(r-1)
%o A228915         n //= 10; r += d; p += 1
%o A228915 # (Based on Tek's PARI program.) - _M. F. Hasler_, Mar 15 2022
%Y A228915 Cf. A007953, A051885, A057168.
%K A228915 base,nonn
%O A228915 1,1
%A A228915 _Paul Tek_, Sep 08 2013