OFFSET
0,3
COMMENTS
Inverse permutation to A098488.
Analogous to A006068 for the decimal base.
For any n, the sequence n, a(n), a(a(n)), a(a(a(n))),... is periodic.
The periods encountered between 0 and 10^6 are:
- 1 (n=0),
- 10 (n=10),
- 5 (n=20),
- 2 (n=50),
- 20 (n=100),
- 4 (n=500),
- 40 (n=10000),
- 8 (n=50000),
- 200 (n=100000),
- 25 (n=200000),
- 50 (n=200010),
- 100 (n=200100).
LINKS
EXAMPLE
1 = 1 mod 10.
1+9 = 0 mod 10.
1+9+5 = 5 mod 10.
1+9+5+4 = 9 mod 10.
Hence, a(1954)=1059.
MATHEMATICA
Table[With[{idn=IntegerDigits[n]}, FromDigits[Table[Mod[Total[Take[idn, i]], 10], {i, Length[idn]}]]], {n, 0, 90}] (* Harvey P. Dale, Mar 08 2015 *)
PROG
(PARI) a(n)=my(b); if(n<10, return(n), b=a(n\10); return(10*b + (b+n)%10))
(PARI) a(n) = my(v=digits(n)); for(i=2, #v, v[i]=(v[i]+v[i-1])%10); fromdigits(v); \\ Kevin Ryde, May 15 2020
(Haskell)
a226134 = foldl (\v d -> 10*v+d) 0 . scanl1 (\d x -> (x+d) `mod` 10) .
map (read . return) . show :: Int -> Int
-- Reinhard Zumkeller, Jun 03 2013
CROSSREFS
KEYWORD
base,easy,nonn
AUTHOR
Paul Tek, May 27 2013
STATUS
approved