OFFSET
1,1
COMMENTS
A prime-semiprime gap of n is defined as the difference between p & q, p being either a prime, A000040, or a semiprime, A001358, and q being the next greater prime or semiprime, see examples.
The corresponding numbers at the end of the prime-semiprime gaps, i.e., a(n)+n, are in A278404.
In the first 52 terms, 19 are primes and the remaining 33 are semiprime. Of the end-of-gap terms a(n)+n, 20 are primes and 32 are not. There are only 6 pairs of p and q that are both primes, and 19 pairs that are both semiprime.
LINKS
Dana Jacobsen, Table of n, a(n) for n = 1..106 (first 52 terms from Bobby Jacobs, Charles R Greathouse IV, Jonathan Vos Post and Robert G. Wilson v)
EXAMPLE
a(1) = 2 since there is a gap of 1 between 2 and 3, both of which are primes.
a(2) = 7 since there is a gap of 2 between 7 and 9, the first is a prime and the second is a semiprime.
a(3) = 26 since there is a gap of 3 between 26, a semiprime, and 29, a prime.
a(6) = 241 because the first prime-semiprime gap of size 6 is between 241 and 247.
MATHEMATICA
nxtp[n_] := Block[{m = n + 1}, While[ PrimeOmega[m] > 2, m++]; m]; gp[_] = 0; p = 2; While[p < 1000000000, q = nxtp[p]; If[ gp[q - p] == 0, gp[q -p] = p; Print[{q -p, p}]]; p = q]; Array[gp, 40]
PROG
(Perl) use ntheory ":all";
my($final, $p, $nextn, @gp) = (40, 2, 1); # first 40 values in order
forfactored {
if (scalar(@_) <= 2) { my $q = $_;
if (!defined $gp[$q-$p]) {
$gp[$q-$p] = $p;
while ($nextn <= $final && defined $gp[$nextn]) {
print "$nextn $gp[$nextn]\n";
$nextn++;
}
lastfor if $nextn > $final;
}
$p = $q;
}
} 3, 10**14; # Dana Jacobsen, Sep 10 2018
CROSSREFS
KEYWORD
nonn
AUTHOR
STATUS
approved