Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #15 Jan 15 2015 10:12:13
%S 0,2,5,3,8,5,12,10,7,2,13,10,23,16,11,9,26,23,4,9,2,13,36,33,28,15,12,
%T 5,34,29,60,58,47,30,23,20,57,38,25,20,61,54,11,0,5,28,75,72,65,60,43,
%U 30,83,80,69,62,43,14,73,68,7,38,31,29,16,5,72,55,32,25
%N a(1)= 0; for n > 1, a(n) = a(n-1) - P(n) if that number is zero or positive, otherwise a(n)= a(n-1)+ P(n), where P(n) is the largest prime factor of n (A006530).
%C a(n) = 0 for n = 1, 44, 125, 373, 1123, 1353, 5071, 19577, …
%H Michel Lagneau, <a href="/A185112/b185112.txt">Table of n, a(n) for n = 1..5000</a>
%p with(numtheory):a0:=0:for n from 2 to 100 do: x:=factorset(n):n1:=nops(x): p:=x[n1]:a1:=a0-p:if a1< 0 then a1:=a0+p:else fi: printf(`%d, `,a1): a0:=a1: od:
%t nxt[{n_,a_}]:=Module[{lpf=FactorInteger[n+1][[-1,1]]},{n+1,If[ a-lpf> = 0,a-lpf,a+lpf]}]; Transpose[NestList[nxt,{1,0},70]][[2]] (* _Harvey P. Dale_, Jan 15 2015 *)
%Y Cf. A006530.
%K nonn
%O 1,2
%A _Michel Lagneau_, Jan 23 2012
%E Definition modified by _Harvey P. Dale_, Jan 15 2015