login
a(n) = Product_{k=1..n-1} gcd(k,n).
9

%I #78 Aug 19 2018 02:37:29

%S 1,1,1,2,1,12,1,16,9,80,1,3456,1,448,2025,2048,1,186624,1,1024000,

%T 35721,11264,1,573308928,625,53248,59049,179830784,1,1007769600000,1,

%U 67108864,7144929,1114112,37515625,160489808068608,1,4980736,89813529

%N a(n) = Product_{k=1..n-1} gcd(k,n).

%C a(n) > 1 if and only if n is composite. - _Charles R Greathouse IV_, Jan 04 2013

%H T. D. Noe, <a href="/A051190/b051190.txt">Table of n, a(n) for n = 1..200</a>

%H OEIS Wiki, <a href="/wiki/Generalizations_of_the_factorial#Formulae_for_GCD_matrix_generalization_of_the_factorial">Generalizations of the factorial</a>

%F a(n) = Product_{ d divides n, d < n } d^phi(n/d). - _Peter Luschny_, Apr 07 2013

%F a(n) = A067911(n) / n. - _Peter Luschny_, Apr 07 2013

%F Product_{j=1..n} Product_{k=1..j-1} gcd(j,k), n >= 1. - _Daniel Forgues_, Apr 11 2013

%F a(n) = sqrt( (1/n) * (A092287(n) / A092287(n-1)) ). - _Daniel Forgues_, Apr 13 2013

%p A051190 := proc(n) local i; mul(igcd(n, i ), i = 1..(n-1)) end;

%t a[n_] := If[PrimeQ[n], 1, Times @@ (GCD[n, #]& /@ Range[n-1])]; Table[a[n], {n, 1, 39}] (* _Jean-François Alcover_, Jul 18 2012 *)

%t Table[Times @@ GCD[n, Range[n-1]], {n, 50}] (* _T. D. Noe_, Apr 12 2013 *)

%o (Haskell)

%o a051190 n = product $ map (gcd n) [1..n-1]

%o -- _Reinhard Zumkeller_, Nov 22 2011

%o (PARI) a(n)=my(f=factor(n)); prod(i=1, #f[,1], prod(j=1, f[i,2], f[i,1]^(n\f[i,1]^j)))/n \\ _Charles R Greathouse IV_, Jan 04 2013

%o (PARI) a(n) = prod(k=1,n-1,gcd(k,n)); /* _Joerg Arndt_, Apr 14 2013 */

%o (Sage)

%o A051190 = lambda n: mul(gcd(n,i) for i in (1..n-1))

%o [A051190(n) for n in (1..39)] # _Peter Luschny_, Apr 07 2013

%o (Sage)

%o # A second, faster version, based on the prime factorization of a(n):

%o def A051190(n):

%o R = 1

%o if not is_prime(n) :

%o for p in primes(n//2+1):

%o s = 0; r = n; t = n-1

%o while r > 0 :

%o r = r//p; t = t//p

%o s += (r-t)*(r+t-1)

%o R *= p^(s/2)

%o return R

%o [A051190(i) for i in (1..1000)] # _Peter Luschny_, Apr 08 2013

%Y Cf. A067911, A006579, A224479, A092287.

%K nonn,nice

%O 1,4

%A _Antti Karttunen_, Oct 21 1999