OFFSET
1,2
COMMENTS
Let d be the number of digits of m (in base 10). One can show that the number m is a member of this sequence if and only if:
(a) m is divisible by d and m >= 10^(d-1) * d/(d+1)
or
(b) 10^(d-1) == 1 (mod d-1) (i.e., d-1 is a term of A014950) and m < 10^d * d/(d+1).
EXAMPLE
13 is a term because the concatenation of 13, 12, ..., 5 is a 13-digit number.
100 is not a term because the concatenation of 100, 99, ..., 52 is a 99-digit number and concatenating this number with 51 yields a 101-digit number.
MATHEMATICA
SelfDownwardConsecutiveQ[n_] :=
Module[{len = Length@IntegerDigits[n], num, c = 1, numDigits = 0},
numDigits = len*Ceiling[n + 1 - 10^(len - 1)];
If[numDigits >= n, Return[Mod[n, len] == 0]];
num = n - Ceiling[n + 1 - 10^(len - 1)];
While[numDigits < n + 1,
If[(len - c)*Ceiling[num + 1 - 10^(len - c - 1)] >= n - numDigits,
Return[Mod[n - numDigits, len - c] == 0],
numDigits += (len - c)*Ceiling[num + 1 - 10^(len - c - 1)]
];
num -= Ceiling[num + 1 - 10^(len - c - 1)];
c++;
]
]
Select[Range[1000], SelfDownwardConsecutiveQ]
CROSSREFS
KEYWORD
easy,nonn,base
AUTHOR
Nicholas M. R. Frieler, Aug 19 2024
STATUS
approved