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.

A240024 Nonprime EKG sequence, cf. A064413: a(1) = 1, a(2) = 4 and for n > 2, a(n) = smallest composite number not already used which shares a factor with a(n-1).

Original entry on oeis.org

1, 4, 6, 8, 10, 12, 9, 15, 18, 14, 16, 20, 22, 24, 21, 27, 30, 25, 35, 28, 26, 32, 34, 36, 33, 39, 42, 38, 40, 44, 46, 48, 45, 50, 52, 54, 51, 57, 60, 55, 65, 70, 49, 56, 58, 62, 64, 66, 63, 69, 72, 68, 74, 76, 78, 75, 80, 82, 84, 77, 88, 86, 90, 81, 87, 93
Offset: 1

Views

Author

Reinhard Zumkeller, Apr 30 2014

Keywords

Comments

A239965 gives the position of the n-th nonprime; a(A239965(n))=A018252(n).

Crossrefs

Cf. A064413, A064664 (EKG sequence).

Programs

  • Haskell
    import Data.List (delete, genericIndex)
    a240024 n = genericIndex a240024_list (n - 1)
    a240024_list = 1 : ekg 4 a002808_list where
       ekg x zs = f zs where
           f (y:ys) = if gcd x y > 1 then y : ekg y (delete y zs) else f ys
  • Mathematica
    a = {1, 4}; Do[k = 6; While[Or[PrimeQ@ k, MemberQ[a, k], CoprimeQ[a[[i - 1]], k]], k++]; AppendTo[a, k], {i, 3, 66}]; a (* Michael De Vlieger, Sep 01 2016 *)