OFFSET
0,4
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 0..9999
MAPLE
a:= proc(n) option remember; `if`(n<1, 0, ((s, t)-> s+
`if`(s<t, t, -t))(a(n-1), numtheory[phi](n)))
end:
seq(a(n), n=0..80); # Alois P. Heinz, Jan 11 2020
MATHEMATICA
a[0] = 0; a[n_] := a[n] = With[{phi = EulerPhi[n], a1 = a[n-1]}, If[phi>a1, a1+phi, a1-phi]];
a /@ Range[0, 80] (* Jean-François Alcover, Nov 01 2020 *)
nxt[{n_, a_}]:=Module[{ph=EulerPhi[n+1]}, {n+1, If[ph>a, a+ph, a-ph]}]; NestList[nxt, {0, 0}, 80][[;; , 2]] (* Harvey P. Dale, Jun 14 2023 *)
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Sep 12 2019
STATUS
approved