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.

A103683 a(1)=1, a(2)=2, a(3)=3, a(n) = smallest positive integer not occurring earlier in sequence and coprime to a(n-1), a(n-2) and a(n-3).

Original entry on oeis.org

1, 2, 3, 5, 7, 4, 9, 11, 13, 8, 15, 17, 19, 14, 23, 25, 27, 16, 29, 31, 21, 10, 37, 41, 33, 20, 43, 47, 39, 22, 35, 53, 51, 26, 49, 55, 57, 32, 59, 61, 45, 28, 67, 71, 65, 6, 73, 77, 79, 12, 83, 85, 89, 18, 91, 95, 97, 24, 101, 103, 107, 30, 109, 113, 119, 36, 115, 121, 127, 34
Offset: 1

Views

Author

Leroy Quet, Mar 26 2005

Keywords

Comments

Conjectured to be not a permutation of the natural numbers.
Charles R Greathouse IV extended this, and confirms that primes occur in natural order. - Jonathan Vos Post and M. F. Hasler, Jan 18 2011
Conjecture: for n >= 67, a(n) is even if and only if n == 2 (mod 4) and divisible by 3 if and only if n == 3 (mod 4). In particular, this implies the last value divisible by 6 is a(66) = 36. - Robert Israel, May 12 2015
a(102982) = 42, see A105214. Conjecture above is false. - Sergio Pimentel, Apr 18 2022

Crossrefs

Programs

  • Maple
    ina:= proc(n) false end:
    a:= proc(n) option remember; local k;
          if n<4 then k:= n
        else for k from 4 while ina(k) or igcd(k, a(n-1))<>1 or
                    igcd(k, a(n-2))<>1 or igcd(k, a(n-3))<>1
             do od
          fi; ina(k):= true; k
        end:
    seq(a(n), n=1..120);  # Alois P. Heinz, Jan 19 2011
  • Mathematica
    f[s_] := Block[{k = 1, l = Take[s, -3]}, While[ Union[ GCD[k, l]] != {1} || MemberQ[s, k], k++]; Append[s, k]]; Nest[f, {1, 2, 3}, 70] (* Robert G. Wilson v, Jun 26 2011 *)
  • Python
    from math import gcd
    from itertools import islice
    def agen(): # generator of terms
        aset, b, c, d = {1, 2, 3, 5}, 2, 3, 5
        yield from [1, b, c, d]
        while True:
            k = 1
            while k in aset or any(gcd(t, k) != 1 for t in [b, c, d]): k+= 1
            b, c, d = c, d, k
            aset.add(k)
            yield k
    print(list(islice(agen(), 70))) # Michael S. Branicky, Apr 18 2022

Extensions

More terms from Robert G. Wilson v, Mar 30 2005