OFFSET
1,5
COMMENTS
n is prime if and only if a(n) = 2*a(n-1) + n - 2.
LINKS
Robert Israel, Table of n, a(n) for n = 1..6636
FORMULA
a(n) = Sum_{k<n} (2^(n mod k) - 1).
G.f.: Sum_{k>=1} ((2^k-2)*z^(2*k+1)+(1-2^k)*z^(2*k)+z^(k+1))/((1-z^k)*(1-z)*(1-2*z)).
EXAMPLE
2^5-1 == 0 (mod 2^1-1), == 1 (mod 2^2-1), == 3 (mod 2^3-1), == 1 (mod 2^4-1), so a(5) = 0+1+3+1 = 5.
MAPLE
f:= proc(n) local k;
add(2^(n mod k) - 1, k=2..n-1)
end proc:
map(f, [$1..100]);
PROG
(Magma) [0] cat [&+[2^(n mod k)-1:k in [1..n-1]]:n in [2..50]]; // Marius A. Burtea, Nov 06 2019
CROSSREFS
KEYWORD
nonn
AUTHOR
J. M. Bergot and Robert Israel, Nov 06 2019
STATUS
approved