OFFSET
1,2
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
R. J. Mathar, Derivation of formula for 2nd differences
FORMULA
a(n) = Sum_{k=1..n-1} [(n-k) * phi(k)] + min(n,2) = A103116(n-1)+ min(n,2); a(1)=1; a(2)=3; a(3)=5.
a(n) = 2*a(n-1) - a(n-2) + phi(n-1) for n>3.
a(n)-a(n-1) = A002088(n-1), n>=3. (Note the previous formula just says that the 2nd differences are A000010, and this is a trivial consequence.) - R. J. Mathar, Jan 27 2023
EXAMPLE
a(4) = 9: the possible means for a set drawn from {1, 2, 3, 4} are {1, 3/2, 2, 7/3, 5/2, 8/3, 3, 7/2, 4}.
MAPLE
a:= proc(n) option remember; `if`(n<4, [0, 1, 3, 5][n+1],
2*a(n-1)-a(n-2)+numtheory[phi](n-1))
end:
seq(a(n), n=0..50); # Alois P. Heinz, Sep 13 2019
MATHEMATICA
a[n_] := Sum[EulerPhi[k] (n - k), {k, 1, n - 1}] + Min[n, 2]
PROG
(PARI) M135342=List([1, 3, 5]);
A135342(n)=while(n>#M135342, listput(M135342, [-1, 2]*Col(M135342[-2..-1])+eulerphi(#M135342))); M135342[n];
apply(A135342, [1..55]) \\ M. F. Hasler, Jan 24 2023
(Python)
from sympy import totient
def A135342(n, A=[1, 3, 5]):
while n>len(A): A.append(2*A[-1]-A[-2]+totient(len(A)))
return A[n-1] # M. F. Hasler, Jan 24 2023
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Jacob A. Siehler, Feb 16 2008
STATUS
approved