login
Smallest heptagonal number with n distinct prime factors.
5

%I #13 Jul 18 2021 12:19:20

%S 7,18,286,3010,32890,769230,3333330,159189030,16015883940,

%T 477463360374,21643407275490,1148540321999070,18489352726664820,

%U 4561561662153109614,71000485538666794110,14440652550858108745170,927869754030522488795610

%N Smallest heptagonal number with n distinct prime factors.

%C a(18) <= 150849873309136386205130310. - _Donovan Johnson_, Feb 15 2012

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/HeptagonalNumber.html">Heptagonal Numbers</a>.

%e a(9) = 16015883940 = 2^2*3^2*5*7*17*19*23*29*59. 16015883940 is the smallest heptagonal number with 9 distinct prime factors.

%o (Python)

%o from sympy import primefactors

%o def A000566(n): return n*(5*n-3)//2

%o def a(n):

%o k = 1

%o while len(primefactors(A000566(k))) != n: k += 1

%o return A000566(k)

%o print([a(n) for n in range(1, 9)]) # _Michael S. Branicky_, Jul 18 2021

%o (Python) # faster version using heptagonal structure

%o from sympy import primefactors

%o def A000566(n): return n*(5*n-3)//2

%o def A000566_distinct_factors(n):

%o pf1 = primefactors(n)

%o pf2 = primefactors(5*n-3)

%o combined = set(pf1) | set(pf2)

%o return len(combined) if n%4 == 0 or (5*n-3)%4 == 0 else len(combined)-1

%o def a(n):

%o k = 1

%o while A000566_distinct_factors(k) != n: k += 1

%o return A000566(k)

%o print([a(n) for n in range(1, 10)]) # _Michael S. Branicky_, Jul 18 2021

%Y Cf. A000566, A076551, A156236, A156237, A156239.

%K nonn

%O 1,1

%A _Donovan Johnson_, Feb 07 2009

%E a(17) from _Donovan Johnson_, Jul 02 2011