Is there any way I can speed up this prime factor counting function? (I am looking for all numbers in a range with 3 prime factors (counted with multiplicity).)
Omega3[n_Integer] := \[Not] FreeQ[PrimeOmega[n], _?(# == 3 &)]
Omega3Count[n_] := Count[Range@n, _?Omega3]
Not[FreeQ[PrimeOmega[n], _?(# == 3 &)]]
? btw, bad idea to use UpperCase first letter for your function names. They look like build-in commands. $\endgroup$Not
& theFreeQ
!! $\endgroup$Length[PrimeOmega]==3
:P $\endgroup$Table[If[PrimeOmega[n] == 3, n, Sequence @@ {}], {n, 1, 100}]
gives{8, 12, 18, 20, 27, 28, 30, 42, 44, 45, 50, 52, 63, 66, 68, 70, 75, 76, 78, 92, 98, 99}
and it seems faster than what you have using a quick test. May be you can double check $\endgroup$k = 0; Do[If[PrimeOmega[n] == 3, k++], {n, 1, 1000}];
$\endgroup$