OFFSET
1,1
REFERENCES
Eric S. Rowland, A simple prime-generating recurrence, Abstracts Amer. Math. Soc., 29 (No. 1, 2008), p. 50 (Abstract 1035-11-986).
LINKS
Indranil Ghosh, Table of n, a(n) for n = 1..50000 (terms 1..1000 from T. D. Noe)
Eric S. Rowland, A simple prime-generating recurrence, arXiv:0710.3217 [math.NT], 2007-2008.
MAPLE
S := 4; f := proc(n) option remember; global S; if n=1 then S else f(n-1)+igcd(n, f(n-1)); fi; end;
MATHEMATICA
a[1]= 4; a[n_]:= a[n]= a[n-1] + GCD[n, a[n-1]]; Table[a[n], {n, 70}]
nxt[{n_, a_}]:= {n+1, a + GCD[a, n+1]}; NestList[nxt, {1, 4}, 70][[All, 2]] (* Harvey P. Dale, Dec 25 2018 *)
PROG
(Maxima) a[1]:4$ a[n]:=a[n-1]+gcd(a[n-1], n)$ makelist(a[n], n, 1, 66); /* Bruno Berselli, May 24 2011 */
(Magma) [n eq 1 select 4 else Self(n-1)+Gcd(Self(n-1), n): n in [1..66]]; // Bruno Berselli, May 24 2011
(Haskell)
a084662 n = a084662_list !! (n-1)
a084662_list =
4 : zipWith (+) a084662_list (zipWith gcd a084662_list [2..])
-- Reinhard Zumkeller, Nov 15 2013
(SageMath)
@CachedFunction
def a(n): # a = A084662
if (n==1): return 4
else: return a(n-1) + gcd(a(n-1), n)
[a(n) for n in range(1, 71)] # G. C. Greubel, Mar 22 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Matthew Frank (mfrank(AT)wopr.wolfram.com) on behalf of the 2003 New Kind of Science Summer School, Jul 15 2003
STATUS
approved