OFFSET
0,3
FORMULA
For n=a, trace(M) = a;
for n=ab, trace(M) = 2a;
for n=abc, trace(M) = a + b + c;
for n=abcd, trace(M) = 2a + 2c.
EXAMPLE
a(123) = 6, because M =
[1 2 3]
[2 3 1]
[3 1 2]
and trace(M) = 6.
PROG
(Sage)
def A177895(n):
d = n.digits()[::-1] if n > 0 else [0]
M = Matrix(lambda i, j: d[(i+j) % len(d)], nrows=len(d))
return M.trace() # D. S. McNeil, Dec 16 2010
(PARI) a(n) = {if(n<10, return(n)); my(d = digits(n), m, s); d = concat(d, d); s = #d/2; m = matrix(s, s, i, j, d[i+j-1]); trace(m)} \\ David A. Corneth, Jun 13 2017
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Michel Lagneau, Dec 15 2010
STATUS
approved