%I #24 Dec 21 2020 07:22:07
%S 0,1,0,2,3,1,2,4,0,5,3,6,1,7,4,8,0,5,2,6,9,10,3,7,11,1,12,4,13,8,2,9,
%T 14,5,15,10,6,16,3,0,17,11,12,4,18,13,19,1,7,20,8,21,14,5,22,0,15,23,
%U 16,9,2,24,17,25,6,10,26,3,18,27,11,7,28,19,1,29,12,20,2,21,4,30,8,31,13,22
%N Difference between the prime indices of the two factors of the n-th semiprime.
%C Are there no adjacent equal terms? I have verified this up to n = 10^6. - _Gus Wiseman_, Dec 04 2020
%H Robert Israel, <a href="/A176506/b176506.txt">Table of n, a(n) for n = 1..10000</a>
%F a(n) = A049084(A084127(n)) - A049084(A084126(n)). [corrected by _R. J. Mathar_, Apr 22 2010]
%F a(n) = A338913(n) - A338912(n). - _Gus Wiseman_, Dec 04 2020
%e From _Gus Wiseman_, Dec 04 2020: (Start)
%e The sequence of semiprimes together with the corresponding differences begins:
%e 4: 1 - 1 = 0
%e 6: 2 - 1 = 1
%e 9: 2 - 2 = 0
%e 10: 3 - 1 = 2
%e 14: 4 - 1 = 3
%e 15: 3 - 2 = 1
%e 21: 4 - 2 = 2
%e 22: 5 - 1 = 4
%e 25: 3 - 3 = 0
%e 26: 6 - 1 = 5
%e 33: 5 - 2 = 3
%e (End)
%p isA001358 := proc(n) numtheory[bigomega](n) = 2 ; end proc:
%p A001358 := proc(n) option remember ; if n = 1 then return 4 ; else for a from procname(n-1)+1 do if isA001358(a) then return a; end if; end do; end if; end proc:
%p A084126 := proc(n) min(op(numtheory[factorset](A001358(n)))) ; end proc:
%p A084127 := proc(n) max(op(numtheory[factorset](A001358(n)))) ; end proc:
%p A176506 := proc(n) numtheory[pi](A084127(n)) - numtheory[pi](A084126(n)) ; end proc: seq(A176506(n),n=1..120) ; # _R. J. Mathar_, Apr 22 2010
%p # Alternative:
%p N:= 500: # to use the first N semiprimes
%p Primes:= select(isprime, [2,seq(i,i=3..N/2,2)]):
%p SP:= NULL:
%p for i from 1 to nops(Primes) do
%p for j from 1 to i do
%p sp:= Primes[i]*Primes[j];
%p if sp > N then break fi;
%p SP:= SP, [sp, i-j]
%p od od:
%p SP:= sort([SP],(s,t) -> s[1]<t[1]):
%p map(t -> t[2], SP); # _Robert Israel_, Jan 17 2019
%t M = 500; (* to use the first M semiprimes *)
%t primes = Select[Join[{2}, Range[3, M/2, 2]], PrimeQ];
%t SP = {};
%t For[i = 1, i <= Length[primes], i++,
%t For[j = 1, j <= i, j++,
%t sp = primes[[i]] primes[[j]];
%t If[sp > M, Break []];
%t AppendTo[SP, {sp, i - j}]
%t ]];
%t SortBy[SP, First][[All, 2]] (* _Jean-François Alcover_, Jul 18 2020, after _Robert Israel_ *)
%t Table[If[!SquareFreeQ[n],0,-Subtract@@PrimePi/@First/@FactorInteger[n]],{n,Select[Range[100],PrimeOmega[#]==2&]}] (* _Gus Wiseman_, Dec 04 2020 *)
%o (PARI) lista(nn) = {my(vsp = select(x->(bigomega(x)==2), [1..nn])); vector(#vsp, k, my(f=factor(vsp[k])[,1]); primepi(vecmax(f)) - primepi(vecmin(f)));} \\ _Michel Marcus_, Jul 18 2020
%Y Cf. A109313.
%Y Cf. A001358, A049084, A084126, A084127.
%Y A087794 is product of the same indices.
%Y A176504 is the sum of the same indices.
%Y A115392 lists positions of first appearances.
%Y A128301 lists positions of 0's.
%Y A172348 lists positions of 1's.
%Y A338898 has this sequence as row differences.
%Y A338900 is the squarefree case.
%Y A338912/A338913 give the two prime indices of semiprimes.
%Y A006881 lists squarefree semiprimes.
%Y A024697 is the sum of semiprimes of weight n.
%Y A056239 gives sum of prime indices (Heinz weight).
%Y A087112 groups semiprimes by greater factor.
%Y A270650/A270652/A338899 give the prime indices of squarefree semiprimes.
%Y A338904 groups semiprimes by weight.
%Y A338907/A338906 list semiprimes of odd/even weight.
%Y A339114/A339115 give the least/greatest semiprime of weight n.
%Y Cf. A000040, A001222, A062198, A112141, A112798, A325699, A320655, A339005.
%K nonn,look
%O 1,4
%A _Juri-Stepan Gerasimov_, Apr 19 2010
%E a(51) and a(69) corrected by _R. J. Mathar_, Apr 22 2010