OFFSET
0,5
COMMENTS
The -1 entries in this sequence correspond to A003052, the self numbers.
This sequence has several terms in common with A025804 (as long as we match -1's with 0's), the expansion of 1/((1-x^2)(1-x^4)(1-x^9)). a(25) to a(34) of that sequence match a(10) to a(19) of the present sequence.
There are 102 -1's in the first 1000 terms here and 983 -1's in the first 10000 terms. - Harvey P. Dale, Feb 22 2016
LINKS
Harvey P. Dale, Table of n, a(n) for n = 0..1000
Max A. Alekseyev and N. J. A. Sloane, On Kaprekar's Junction Numbers, arXiv:2112.14365, 2021; Journal of Combinatorics and Number Theory 12:3 (2022), 115-155.
Eric Weisstein's World of Mathematics, Digit Addition Generator.
EXAMPLE
a(0) = 0 because 0 + 0 = 0
a(1) = -1 because there is no nonnegative integer that added to its digits-sum results in 1
a(29) = 19 because 19 + (1 + 9) = 29
a(30) = 24 because 24 + (2 + 4) = 30
a(31) = -1 because there is no integer that added to its digits-sum results in 31
MATHEMATICA
msodm[n_]:=Module[{m=n-9*IntegerLength[n]}, While[m+Total[ IntegerDigits[ m]] != n&&m<n, m++]; If[m+Total[IntegerDigits[m]]==n, m, -1]]; Array[ msodm, 80, 0] (* Harvey P. Dale, Feb 22 2016, updated Dec 31 2021 *)
PROG
(PARI)
/* Gen(n, b) returns a list of the generators of n in base b. Written by Max Alekseyev (see Alekseyev et al., 2021).
For example, Gen(101, 10) returns [91, 101]. - N. J. A. Sloane, Jan 02 2022 */
{ Gen(u, b=10) = my(d, m, k);
if(u<0 || u==1, return([]); );
if(u==0, return([0]); );
d = #digits(u, b)-1;
m = u\b^d;
while( sumdigits(m, b) > u - m*b^d,
m--;
if(m==0, m=b-1; d--; );
);
k = u - m*b^d - sumdigits(m, b);
vecsort( concat( apply(x->x+m*b^d, Gen(k, b)),
apply(x->m*b^d-1-x, Gen((b-1)*d-k-2, b)) ) );
}
CROSSREFS
KEYWORD
base,sign
AUTHOR
Alonso del Arte, Aug 09 2004
EXTENSIONS
Typo in definition corrected by Harvey P. Dale, Feb 22 2016
Edited. Escape clause value changed from 0 to -1, and a(0) = 0 added. - N. J. A. Sloane, Dec 31 2021
STATUS
approved