[go: up one dir, main page]

login
A136712
At step n the sequence lists the number of occurrences of digit (n mod k), with k>0, in all the numbers from 1 to n. Case k=8.
8
1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 10, 2, 2, 2, 2, 2, 2, 2, 13, 10, 3, 3, 3, 3, 3, 3, 14, 14, 10, 4, 4, 4, 4, 4, 15, 15, 15, 10, 5, 5, 5, 4, 15, 15, 15, 15, 9, 5, 5, 5, 16, 16, 16, 16, 16, 9, 6, 6, 17, 17, 17, 17, 17, 17, 9, 7, 18, 18, 18, 18, 18, 18, 18, 8, 19, 19, 19, 19, 19, 19
OFFSET
0,17
EXAMPLE
For n=17 we have 10 because the digit (17 mod 8)=1 is present 10 times: 1, 10, 11, 12, 13, 14, 15, 16, 17.
For n=20 we have 2 because the digit (20 mod 8)=4 is present twice: 4, 14.
MAPLE
P:=proc(n, m) local a, b, c, d, i, v; v:=array(1..m); for i from 1 to m-1 do v[i]:=1; print(1); od; if m=10 then v[m]:=1; print(1); else v[m]:=0; print(0); fi; for i from m+1 by 1 to n do a:=(i mod m); for b from i-m+1 by 1 to i do d:=b; while d>0 do c:=d-(trunc(d/10)*10); d:=trunc(d/10); if c=a then if a=0 then v[m]:=v[m]+1; else v[a]:=v[a]+1; fi; fi; od; od; if a=0 then print(v[m]); else print(v[a]); fi; od; end: P(101, 8);
KEYWORD
easy,base,nonn
AUTHOR
STATUS
approved