OFFSET
1,2
COMMENTS
This sequence differs from A071980 beginning with n = 1010, and differs formulaically beginning with n = 1000 (the first four digit number). Where A071980 is calculated as a + ab + abc + abcd + bcd + cd + d for four digit numbers abcd, this sequence also includes the term bc in the sum.
Limits: n <= a(n) < 1.73*n. Proof: a(n)/n will be maximized when substrings are as large as possible while n is as small as possible, or for numbers of the form 199999999... The sum of substrings of this number is < 222222... + < 1234567... or < 3456790123.../2000000000... or < 1.728396.
The number 111 is the smallest term that occurs twice in the sequence, when n = {96, 100}. The number 2254 is the smallest term that occurs three times in the sequence, when n = {1476, 1510, 2008}.
LINKS
Christian N. K. Anderson, Table of n, a(n) for n = 1..10000
Christian N. K. Anderson, Ulam spiral of all values of a(n)<10000, color-coded by the number of times they occur.
FORMULA
a(n) = 11*a(floor(n/10)) - 10*a(floor(n/100)) + (n mod 10) * A055642(n). - David Radcliffe, May 15 2025
EXAMPLE
For n=1980, a(n) = 1 + 9 + 8 + 0 + 19 + 98 + 80 + 198 + 980 + 1980 = 3373. Note that A071980(1980) = 3258, because it does not include 9, 8, 98 in the sum.
MAPLE
f:= proc(n) local i, d, L;
L:= convert(n, base, 10);
d:= nops(L);
add(L[i]*(d-i+1)*(10^i - 1)/9, i=1..d);
end proc:
map(f, [$1..100]); # Robert Israel, May 15 2025
MATHEMATICA
Table[s = IntegerDigits[n]; Total[Flatten[Table[FromDigits /@ Partition[s, i, 1], {i, Length[s]}]]], {n, 100}] (* T. D. Noe, May 13 2013 *)
PROG
(R) sapply(1:100, function(n) {tot=0; s=as.character(n); len=nchar(s); for(i in 1:len) for(j in i:len) tot=tot+as.numeric(substr(s, i, j)); tot})
(Python)
def a(n):
s = str(n)
return sum(int(s[i:j]) for j in range(1, len(s)+1) for i in range(j))
# David Radcliffe, May 15 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Christian N. K. Anderson and Kevin L. Schwartz, May 10 2013
EXTENSIONS
Example corrected by Zak Seidov, May 16 2013
STATUS
approved
