OFFSET
1,2
COMMENTS
The sequence is infinite: a(n) always exists.
One could start with a(0) = 0, followed by the given a(n). - M. F. Hasler, Oct 10 2019
REFERENCES
Eric Angelini, Postings to the Sequence Fans Mailing List, Apr 13 2013
LINKS
Eric Angelini, Magic Sums
E. Angelini, Magic Sums [Cached copy, with permission]
EXAMPLE
1+10=11 < 1+1 >
10+99=109 < 10+9 >
99+899=998 < 99+8 >
899+8099=8998 < 899+9 >
8099+72898=80997 < 8099+7 >
...
MATHEMATICA
leadingDigit[x_] := IntegerPart[N[x/10^IntegerPart[Log[10, x]]]];
successor[x_] :=(
y = 1;
If[leadingDigit[z = 9x+y] == y, z,
y = leadingDigit[9x];
If[leadingDigit[z = 9x+y] == y, z,
y += 1;
If[leadingDigit[z = 9x+y] == y, z,
Print["Bug"]]]]);
(* Gilles Esposito-Farèse, Apr 21 2013 *)
PROG
(PHP) <?
/*
calcul de la suite telle que la somme
s(n) + s(n+1) s'obtient en concaténant le
premier chiffre de s(n+1) après s(n).
Eric Angelini, 18/04/2013
*/
function leading_digit ($n) {
return (int) substr("$n", 0, 1) ;
}
function successor ($n) {
$p = 9*$n ;
for ( $a = 1 ; $a <= 9 ; $a++ ) {
if (leading_digit($p+$a) == $a) {
return ($p+$a) ;
}
}
die("nothing found for successor($n)") ;
}
$x = $_REQUEST["x"] ;
$n = $_REQUEST["n"] ;
if ( $n === "0" ) {
for ($i=1 ; $i<=$x ; $i++) {
echo "$i → ", successor($i), "<br>\n" ;
}
} else {
if (! $x) $x = 1 ;
if (! $n) $n = 15 ;
while ($n--) {
echo "$x, " ;
$x = successor($x) ;
}
}
/* Eric Angelini, Apr 21 2013 */
?>
From M. F. Hasler, Oct 10 2019: (Start)
A224752_nxt(x, n=0)={x*=9; while(digits(x++)[1]!=n++, ); x} \\ (End)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Apr 21 2013
STATUS
approved