login
a(n) = c(1)*p(0) + ... + c(n)*p(n-1), where c(i) = 1 if a(i-1) <= p(i-1) and c(i) = -1 if a(i-1) > p(i-1) (with p(0) = 1 and p(i) a prime for i >= 1).
1

%I #24 Nov 14 2019 10:45:10

%S 1,3,6,1,8,19,6,23,4,27,56,25,62,21,64,17,70,11,72,5,76,3,82,165,76,

%T 173,72,175,68,177,64,191,60,197,58,207,56,213,50,217,44,223,42,233,

%U 40,237,38,249,26,253,24,257,18,259,8,265,2,271,542,265,546,263,556

%N a(n) = c(1)*p(0) + ... + c(n)*p(n-1), where c(i) = 1 if a(i-1) <= p(i-1) and c(i) = -1 if a(i-1) > p(i-1) (with p(0) = 1 and p(i) a prime for i >= 1).

%C Alternate description: a(1) = 1, a(n) = a(n-1) - prime(n) if a(n-1) > prime(n) else a(n) = a(n-1) + prime(n). - _Amarnath Murthy_ and Meenakshi Srikanth (menakan_s(AT)yahoo.com), Jun 27 2003

%H Harvey P. Dale, <a href="/A022836/b022836.txt">Table of n, a(n) for n = 0..1000</a>

%F a(n) = A008348(n) + 1.

%t nxt[{n_,a_}]:=Module[{p=Prime[n]},{n+1,If[a>p,a-p,a+p]}]; NestList[ nxt,{1,1},70][[All,2]] (* _Harvey P. Dale_, Nov 27 2016 *)

%K nonn

%O 0,2

%A _Clark Kimberling_

%E Name corrected by _Sean A. Irvine_, May 22 2019