%I #22 Aug 21 2021 10:32:14
%S 8,21,280,1680,38760,326040,10986360,185040240,4897368840,
%T 383246454360,13143876816840,376306806515640,27961718389364760,
%U 3250163645572822440,152582219844376633080,6202664616058189439160,1454199694916714984358120
%N Smallest octagonal number with n distinct prime factors.
%C a(18) <= 68286531655807008335271480. - _Donovan Johnson_, Feb 15 2012
%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/OctagonalNumber.html">Octagonal Numbers</a>.
%e a(9) = 4897368840 = 2^3*3*5*7*13*17*23*31*37. 4897368840 is the smallest octagonal number with 9 distinct prime factors.
%t f[n_] := PrimeNu@ n; nn = 10; k = 1; t = Table[0, {nn}]; While[Times@@t == 0, oct = k(3k-2); a = f@ oct; If[ a <= nn && t[[a]] == 0, t[[a]] = k; Print[{a, oct}]]; k++]; t (* _Robert G. Wilson v_, Aug 23 2012 *)
%o (Python)
%o from sympy import primefactors
%o def octagonal(n): return n*(3*n - 2)
%o def a(n):
%o k = 1
%o while len(primefactors(octagonal(k))) != n: k += 1
%o return octagonal(k)
%o print([a(n) for n in range(1, 10)]) # _Michael S. Branicky_, Aug 21 2021
%o (Python) # faster version using octagonal structure
%o from sympy import primefactors, primorial
%o def A000567(n): return n*(3*n-2)
%o def A000567_distinct_factors(n):
%o return len(set(primefactors(n)) | set(primefactors(3*n-2)))
%o def a(n):
%o k, lb = 1, primorial(n)
%o while A000567(k) < lb: k += 1
%o while A000567_distinct_factors(k) != n: k += 1
%o return A000567(k)
%o print([a(n) for n in range(1, 10)]) # _Michael S. Branicky_, Aug 21 2021
%Y Cf. A000567, A076551, A156236, A156237, A156238.
%K nonn
%O 1,1
%A _Donovan Johnson_, Feb 07 2009
%E a(17) from _Donovan Johnson_, Jul 03 2011