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.

A334085 GCD of n and the product of all primes < n.

Original entry on oeis.org

1, 1, 1, 2, 1, 6, 1, 2, 3, 10, 1, 6, 1, 14, 15, 2, 1, 6, 1, 10, 21, 22, 1, 6, 5, 26, 3, 14, 1, 30, 1, 2, 33, 34, 35, 6, 1, 38, 39, 10, 1, 42, 1, 22, 15, 46, 1, 6, 7, 10, 51, 26, 1, 6, 55, 14, 57, 58, 1, 30, 1, 62, 21, 2, 65, 66, 1, 34, 69, 70, 1, 6, 1, 74, 15
Offset: 1

Views

Author

Christoph Schreier, Apr 14 2020

Keywords

Comments

a(n) = 1 iff n is prime or n = 1.

Examples

			For n=8 the product of all primes < 8 = A034386(7) = 210; gcd(8,210) = 2.
		

Crossrefs

Programs

  • Maple
    a:= n-> `if`(isprime(n), 1, mul(i[1], i=ifactors(n)[2])):
    seq(a(n), n=1..80);  # Alois P. Heinz, Apr 17 2020
  • Mathematica
    a[n_] := GCD[n, Times @@ Select[Range[n - 1], PrimeQ]]; Array[a, 60] (* Amiram Eldar, Apr 14 2020 *)
  • PARI
    a(n) = gcd(n, prod(k=1, n-1, if (isprime(k), k, 1))); \\ Michel Marcus, Apr 14 2020
    
  • PARI
    a(n,f=factor(n))=if(f[,2]==[1]~,1,factorback(f[,1])) \\ Charles R Greathouse IV, Apr 14 2020
  • Python
    def is_prime(n):
        if n == 2 or n == 3:
            return True
        if n % 2 == 0 or n < 2:
            return False
        for i in range(3,int(n**0.5)+1,2):
            if n % i == 0:
                return False
        return True
    def A(n):
        if n < 3:
            raise ValueError('n must be > 2')
        else:
            a = 1
            for i in range(n):
                if is_prime(i):
                    a *= i
        return math.gcd(n,a)
    

Formula

a(n) = gcd(n, A034386(n-1)).
a(n) = 1 if n is prime, else a(n) = A007947(n).