%I #40 Oct 10 2019 20:29:20
%S 1,10,99,899,8099,72898,656088,5904797,53143178,478288606,4304597458,
%T 38741377125,348672394128,3138051547155,28242463924397,
%U 254182175319575,2287639577876177,20588756200885595,185298805807970356,1667689252271733205,15009203270445598846,135082829434010389615
%N a(1)=1; thereafter a(n) = smallest number m such that a(n-1)+m = (a(n-1) followed by the leading digit of m).
%C The sequence is infinite: a(n) always exists.
%C One could start with a(0) = 0, followed by the given a(n). - _M. F. Hasler_, Oct 10 2019
%D Eric Angelini, Postings to the Sequence Fans Mailing List, Apr 13 2013
%H Eric Angelini, <a href="http://www.cetteadressecomportecinquantesignes.com/MagicalSum.htm">Magic Sums</a>
%H E. Angelini, <a href="/A224752/a224752.pdf">Magic Sums</a> [Cached copy, with permission]
%e 1+10=11 < 1+1 >
%e 10+99=109 < 10+9 >
%e 99+899=998 < 99+8 >
%e 899+8099=8998 < 899+9 >
%e 8099+72898=80997 < 8099+7 >
%e ...
%t leadingDigit[x_] := IntegerPart[N[x/10^IntegerPart[Log[10, x]]]];
%t successor[x_] :=(
%t y = 1;
%t If[leadingDigit[z = 9x+y] == y, z,
%t y = leadingDigit[9x];
%t If[leadingDigit[z = 9x+y] == y, z,
%t y += 1;
%t If[leadingDigit[z = 9x+y] == y, z,
%t Print["Bug"]]]]);
%t (* Gilles Esposito-Farèse, Apr 21 2013 *)
%o (PHP) <?
%o /*
%o calcul de la suite telle que la somme
%o s(n) + s(n+1) s'obtient en concaténant le
%o premier chiffre de s(n+1) après s(n).
%o Eric Angelini, 18/04/2013
%o */
%o function leading_digit ($n) {
%o return (int) substr("$n", 0, 1) ;
%o }
%o function successor ($n) {
%o $p = 9*$n ;
%o for ( $a = 1 ; $a <= 9 ; $a++ ) {
%o if (leading_digit($p+$a) == $a) {
%o return ($p+$a) ;
%o }
%o }
%o die("nothing found for successor($n)") ;
%o }
%o $x = $_REQUEST["x"] ;
%o $n = $_REQUEST["n"] ;
%o if ( $n === "0" ) {
%o for ($i=1 ; $i<=$x ; $i++) {
%o echo "$i → ", successor($i), "<br>\n" ;
%o }
%o } else {
%o if (! $x) $x = 1 ;
%o if (! $n) $n = 15 ;
%o while ($n--) {
%o echo "$x, " ;
%o $x = successor($x) ;
%o }
%o }
%o /* _Eric Angelini_, Apr 21 2013 */
%o ?>
%o From _M. F. Hasler_, Oct 10 2019: (Start)
%o (PARI) A224752_vec(N=30)=vector(N,n,N=A224752_nxt((n>1)*N))
%o A224752_nxt(x,n=0)={x*=9; while(digits(x++)[1]!=n++,); x} \\ (End)
%Y Cf. A224752-A224761.
%K nonn,base
%O 1,2
%A _N. J. A. Sloane_, Apr 21 2013
|