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.

A078840 Table of n-almost-primes T(n,k) (n >= 0, k > 0), read by antidiagonals, starting at T(0,1)=1 followed by T(1,1)=2.

This page as a plain text file.
%I A078840 #80 Aug 17 2025 08:22:54
%S A078840 1,2,3,4,5,6,8,7,9,12,16,11,10,18,24,32,13,14,20,36,48,64,17,15,27,40,
%T A078840 72,96,128,19,21,28,54,80,144,192,256,23,22,30,56,108,160,288,384,512,
%U A078840 29,25,42,60,112,216,320,576,768,1024,31,26,44,81,120,224,432,640,1152
%N A078840 Table of n-almost-primes T(n,k) (n >= 0, k > 0), read by antidiagonals, starting at T(0,1)=1 followed by T(1,1)=2.
%C A078840 An n-almost-prime is a positive integer that has exactly n prime factors.
%C A078840 This sequence is a rearrangement of the natural numbers. - _Robert G. Wilson v_, Feb 11 2006
%C A078840 Each antidiagonal begins with the n-th prime and ends with 2^n.
%C A078840 From _Eric Desbiaux_, Jun 27 2009: (Start)
%C A078840 (A001222 gives this sequence)
%C A078840 A001221 gives another table:
%C A078840   1
%C A078840   -    2    3    4    5    7    8    9   11 ... A000961
%C A078840   -    6   10   12   14   15   18   20   21 ... A007774
%C A078840   -   30   42   60   66   70   78   84   90 ... A033992
%C A078840   -  210  330  390  420  462  510  546  570 ... A033993
%C A078840   - 2310 2730 3570 3990 4290 4620 4830 5460 ... A051270
%C A078840 Antidiagonals begin with A000961 and end with A002110.
%C A078840 Diagonal is A073329 which is last term in n-th row of A048692. (End)
%H A078840 Robert G. Wilson v, <a href="/A078840/b078840.txt">Table of n, a(n) for n = 0..10011</a> (corrected by Ivan Neretin).
%H A078840 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/AlmostPrime.html">Almost Prime</a>.
%e A078840 Table begins:
%e A078840   1
%e A078840   -  2  3   5   7  11  13  17  19  23  29 ...
%e A078840   -  4  6   9  10  14  15  21  22  25  26 ...
%e A078840   -  8 12  18  20  27  28  30  42  44  45 ...
%e A078840   - 16 24  36  40  54  56  60  81  84  88 ...
%e A078840   - 32 48  72  80 108 112 120 162 168 176 ...
%e A078840   - 64 96 144 160 216 224 240 324 336 352 ...
%t A078840 AlmostPrimePi[k_Integer, n_] := Module[{a, i}, a[0] = 1; If[k == 1, PrimePi[n], Sum[PrimePi[n/Times @@ Prime[ Array[a, k - 1]]] - a[k - 1] + 1, Evaluate[ Sequence @@ Table[{a[i], a[i - 1], PrimePi[(n/Times @@ Prime[Array[a, i - 1]])^(1/(k - i + 1))]}, {i, k - 1}]] ]]]; (* _Eric W. Weisstein_, Feb 07 2006 *)
%t A078840 AlmostPrime[k_, n_] := Block[{e = Floor[Log[2, n]+k], a, b}, a = 2^e; Do[b = 2^p; While[ AlmostPrimePi[k, a] < n, a = a + b]; a = a - b/2, {p, e, 0, -1}]; a + b/2]; Table[ AlmostPrime[k, n - k + 1], {n, 11}, {k, n}] // Flatten (* _Robert G. Wilson v_ *)
%t A078840 mx = 11; arr = NestList[Take[Union@Flatten@Outer[Times, #, primes], mx] &, primes = Prime@Range@mx, mx]; Prepend[Flatten@Table[arr[[k, n - k + 1]], {n, mx}, {k, n}], 1] (* _Ivan Neretin_, Apr 30 2016 *)
%t A078840 (* The next code skips the initial 1. *)
%t A078840 width = 15; (seq = Table[
%t A078840   Rest[NestList[1 + NestWhile[# + 1 &, #, ! PrimeOmega[#] == z &] &,
%t A078840   2^z, width - z + 1]] - 1, {z, width}]) // TableForm
%t A078840 Flatten[Map[Reverse[Diagonal[Reverse[seq], -width + #]] &, Range[width]]]
%t A078840 (* _Peter J. C. Moses_, Jun 05 2019 *)
%t A078840 Grid[Table[Select[Range[200], PrimeOmega[#] == n &], {n, 0, 7}]]
%t A078840 (* _Clark Kimberling_, Nov 17 2024 *)
%o A078840 (PARI) T(n,k)=if(k<0,0,s=1; while(sum(i=1,s,if(bigomega(i)-n,0,1))<k,s++); s)
%o A078840 (Python)
%o A078840 from math import prod, isqrt
%o A078840 from sympy import primerange, integer_nthroot, primepi, prime
%o A078840 def A078840_T(n,k):
%o A078840     if n == 1: return prime(k)
%o A078840     def g(x,a,b,c,m): yield from (((d,) for d in enumerate(primerange(b,isqrt(x//c)+1),a)) if m==2 else (((a2,b2),)+d for a2,b2 in enumerate(primerange(b,integer_nthroot(x//c,m)[0]+1),a) for d in g(x,a2,b2,c*b2,m-1)))
%o A078840     def f(x): return int(k-1+x-sum(primepi(x//prod(c[1] for c in a))-a[-1][0] for a in g(x,0,1,1,n)))
%o A078840     kmin, kmax = 1,2
%o A078840     while f(kmax) >= kmax:
%o A078840         kmax <<= 1
%o A078840     while True:
%o A078840         kmid = kmax+kmin>>1
%o A078840         if f(kmid) < kmid:
%o A078840             kmax = kmid
%o A078840         else:
%o A078840             kmin = kmid
%o A078840         if kmax-kmin <= 1:
%o A078840             break
%o A078840     return kmax # _Chai Wah Wu_, Aug 23 2024
%Y A078840 Cf. A078840, A078841, A078842, A078843, A078844, A078445, A078846, A109636.
%Y A078840 T(1, k)=A000040(k), T(2, k)=A001358(k), T(3, k)=A014612(k), T(4, k)=A014613(k), T(5, k)=A014614(k), T(6, k)=A046306(k), T(7, k)=A046308(k), T(8, k)=A046310(k), T(9, k)=A046312(k), T(10, k)=A046314(k).
%Y A078840 T(11, k)=A069272(k), T(12, k)=A069273(k), T(13, k)=A069274(k), T(14, k)=A069275(k), T(15, k)=A069276(k), T(16, k)=A069277(k), T(17, k)=A069278(k), T(18, k)=A069279(k), T(19, k)=A069280(k), T(20, k)=A069281(k).
%Y A078840 T(k, 1)=A000079(k), T(k, 2)=A007283(k), T(k, 3)=A116453(k), T(k, k)=A101695(k), T(k, k+1)=A078841(k).
%Y A078840 A091538 is this sequence with zeros inserted, making a square array.
%K A078840 nonn,tabf,hear,changed
%O A078840 0,2
%A A078840 _Benoit Cloitre_ and _Paul D. Hanna_, Dec 10 2002
%E A078840 Edited by _Robert G. Wilson v_, Feb 11 2006