A167493 a(1) = 2; thereafter a(n) = a(n-1) + gcd(n, a(n-1)) if n is odd, and a(n) = a(n-1) + gcd(n-2, a(n-1)) if n is even.
2, 4, 5, 6, 7, 8, 9, 12, 15, 16, 17, 18, 19, 20, 25, 26, 27, 28, 29, 30, 33, 34, 35, 36, 37, 38, 39, 52, 53, 54, 55, 60, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 124, 125, 126
Offset: 1
Keywords
Links
- Bill McEachen, Table of n, a(n) for n = 1..100000
- E. S. Rowland, A natural prime-generating recurrence, Journal of Integer Sequences, Vol.11 (2008), Article 08.2.8.
- Vladimir Shevelev, A new generator of primes based on the Rowland idea, arXiv:0910.4676 [math.NT], 2009.
- Vladimir Shevelev, Three theorems on twin primes, arXiv:0911.5478 [math.NT], 2009-2010.
Crossrefs
Programs
-
Mathematica
nxt[{n_,a_}]:={n+1,If[EvenQ[n],a+GCD[n+1,a],a+GCD[n-1,a]]}; Transpose[ NestList[nxt,{1,2},70]][[2]] (* Harvey P. Dale, Dec 05 2015 *)
-
PARI
lista(nn)=my(va = vector(nn)); va[1] = 2; for (n=2, nn, va[n] = if (n%2, va[n-1] + gcd(n, va[n-1]), va[n-1] + gcd(n-2, va[n-1]));); va; \\ Michel Marcus, Dec 13 2018
-
Python
from math import gcd from itertools import count, islice def agen(): # generator of terms an = 2 for n in count(2): yield an an = an + gcd(n, an) if n&1 else an + gcd(n-2, an) print(list(islice(agen(), 66))) # Michael S. Branicky, Jan 22 2023
Formula
For n > 3, n < a(n) < n*(n-1)/2. - Charles R Greathouse IV, Jan 22 2023
Extensions
More terms from Harvey P. Dale, Dec 05 2015
Comments