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.

A252865 a(n) = n if n <= 3, otherwise the smallest squarefree number not occurring earlier having at least one common factor with a(n-2), but none with a(n-1).

Original entry on oeis.org

1, 2, 3, 10, 21, 5, 6, 35, 22, 7, 11, 14, 33, 26, 15, 13, 30, 91, 34, 39, 17, 42, 85, 38, 51, 19, 66, 95, 46, 55, 23, 65, 69, 70, 57, 58, 93, 29, 31, 87, 62, 105, 74, 77, 37, 110, 111, 82, 129, 41, 43, 123, 86, 141, 106, 47, 53, 94, 159, 118, 165, 59, 78, 295
Offset: 1

Views

Author

Keywords

Comments

Similar to A098550, but the restriction to squarefree makes it more a sequence of sets of primes, represented by their product.
The sequence has consecutive primes at indices 2 (2 & 3), 10 (7 & 11), 38 (29 & 31), 50 (41 & 43), and 56 (47 & 53). We conjecture that there are no further such pairs.

Crossrefs

Programs

  • Haskell
    import Data.List (delete)
    a252865 n = a252865_list !! (n-1)
    a252865_list = 1 : 2 : 3 : f 2 3 (drop 3 a005117_list) where
       f u v ws = g ws where
         g (x:xs) = if gcd x u > 1 && gcd x v == 1
                       then x : f v x (delete x ws) else g xs
    -- Reinhard Zumkeller, Dec 24 2014
    
  • Mathematica
    a[n_ /; n <= 3] = n;
    a[n_] := a[n] = For[k = 1, True, k++, If[SquareFreeQ[k], If[FreeQ[Array[a, n-1], k], If[!CoprimeQ[k, a[n-2]] && CoprimeQ[k, a[n-1]], Return[k]]]]];
    Array[a, 100] (* Jean-François Alcover, Sep 02 2018 *)
  • PARI
    invecn(v, k, x)=for(i=1, k, if(v[i]==x, return(i))); 0
    alist(n)=local(v=vector(n,i,i), x); for(k=4, n, x=4; while(!issquarefree(x)||invecn(v, k-1, x)||gcd(v[k-2], x)==1||gcd(v[k-1],x)!=1, x++); v[k]=x); v
    
  • Python
    from math import gcd
    from sympy import factorint
    A252865_list, l1, l2, s, b = [1,2,3], 3, 2, 4, set()
    for _ in range(10**2):
        i = s
        while True:
            if max(factorint(i).values()) == 1:
                if not i in b and gcd(i,l1) == 1 and gcd(i,l2) > 1:
                    A252865_list.append(i)
                    l2, l1 = l1, i
                    b.add(i)
                    while s in b:
                        b.remove(s)
                        s += 1
                    break
            else:
                b.add(i)
            i += 1 # Chai Wah Wu, Dec 24 2014
    
  • Python
    from math import gcd
    from sympy import factorint
    from itertools import count, islice
    def issquarefree(n): return max(factorint(n).values()) == 1
    def agen(): # generator of terms
        aset, an2, an1, m = {1, 2, 3}, 2, 3, 4
        yield from sorted(aset)
        while True:
            an = next(k for k in count(m) if k not in aset and gcd(k, an2) > 1 and gcd(k, an1) == 1 and issquarefree(k))
            an2, an1 = an1, an
            while m in aset or not issquarefree(m): m += 1
            aset.add(an)
            yield an
    print(list(islice(agen(), 64))) # Michael S. Branicky, Jan 10 2025