A123196 a(1) = 2; a(n+1) = a(n) + p, where p is the largest prime <= a(n).
2, 4, 7, 14, 27, 50, 97, 194, 387, 770, 1539, 3070, 6137, 12270, 24539, 49072, 98141, 196270, 392517, 785020, 1570037, 3140044, 6280085, 12560152, 25120299, 50240588, 100481175, 200962342, 401924669, 803849308, 1607698611, 3215397194
Offset: 1
Examples
a(1)=2 since 2 is the first prime. a(3)=7 since having landed at 4, the greatest prime reached so far is 3. a(8)=194=97+97 since with the preceding term we had landed on a prime. a(17)=98141 since having passed the prime 49069 with the term a(16) but not having reached the prime 49081, we have to add the former and indeed 98141=49069+49072.
Links
- Giovanni Resta, Table of n, a(n) for n = 1..3322
Programs
-
Maple
a[1]:=2; for k from 1 to 29 do x:=a[k]: if isprime(x) then a[k+1]:=x+x: else y:=x: while not(isprime(y)) do y:=y-1:od; a[k+1]:= x+y: fi;od;
-
Mathematica
a[1]=2; a[n_]:= a[n] = If[PrimeQ[a[n-1]], 2 a[n-1], a[n-1] + NextPrime[ a[n-1], -1]]; Array[a, 100] (* Giovanni Resta, Apr 08 2017 *)
-
PARI
lista(nn) = { print1(a=2, ", "); for (n=2, nn, na = a + precprime(a); print1(na, ", "); a = na;);} \\ Michel Marcus, Apr 08 2017
Extensions
New name from David James Sycamore, Apr 07 2017
Comments