cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A084662 a(1) = 4; a(n) = a(n-1) + gcd(a(n-1), n).

Original entry on oeis.org

4, 6, 9, 10, 15, 18, 19, 20, 21, 22, 33, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 69, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 141, 144, 145, 150, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168
Offset: 1

Views

Author

Matthew Frank (mfrank(AT)wopr.wolfram.com) on behalf of the 2003 New Kind of Science Summer School, Jul 15 2003

Keywords

References

  • Eric S. Rowland, A simple prime-generating recurrence, Abstracts Amer. Math. Soc., 29 (No. 1, 2008), p. 50 (Abstract 1035-11-986).

Crossrefs

Cf. A084663, A106108 and other sequences mentioned in A106108.
Cf. A134734 (first differences), A134736, A230504.

Programs

  • Haskell
    a084662 n = a084662_list !! (n-1)
    a084662_list =
       4 : zipWith (+) a084662_list (zipWith gcd a084662_list [2..])
    -- Reinhard Zumkeller, Nov 15 2013
    
  • Magma
    [n eq 1 select 4 else Self(n-1)+Gcd(Self(n-1),n): n in [1..66]]; // Bruno Berselli, May 24 2011
    
  • 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 *)
  • 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 */
    
  • 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