A022836 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, 3, 6, 1, 8, 19, 6, 23, 4, 27, 56, 25, 62, 21, 64, 17, 70, 11, 72, 5, 76, 3, 82, 165, 76, 173, 72, 175, 68, 177, 64, 191, 60, 197, 58, 207, 56, 213, 50, 217, 44, 223, 42, 233, 40, 237, 38, 249, 26, 253, 24, 257, 18, 259, 8, 265, 2, 271, 542, 265, 546, 263, 556
Offset: 0
Keywords
Links
- Harvey P. Dale, Table of n, a(n) for n = 0..1000
Programs
-
Mathematica
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 *)
Formula
a(n) = A008348(n) + 1.
Extensions
Name corrected by Sean A. Irvine, May 22 2019
Comments