Jelly, 19 bytes
’ÆRḊμ_Æp=2Tịμ_2;μİS
I have a feeling that this is improvable, but I can't immediately see how.
Explanation
’ÆRḊμ_Æp=2Tịμ_2;μİS
ÆR Generate all primes from 2 to n inclusive
’ Subtract 1
Ḋ Remove first element
’ÆRḊ Generate all primes from 3 to n-1 exclusive
_Æp Subtract the previous prime (i.e. calculate the prime gap)
=2 Compare to 2
Tị Take elements of the input where the comparison is true
_Æp=2Tị Filter a list of primes to the latter halves of prime pairs
_2 Subtract 2
; Append
_2; Append the list to the list with 2 subtracted from it
İ Take reciprocals
S Sum
İS Take the sum of the reciprocals
Explanation to comeThe μ connect all these portions together pipeline-style, with each taking the output of the one before as its input.
Jelly, 19 bytes
’ÆRḊμ_Æp=2Tịμ_2;μİS
I have a feeling that this is improvable, but I can't immediately see how.
Explanation to come.
Jelly, 19 bytes
’ÆRḊμ_Æp=2Tịμ_2;μİS
I have a feeling that this is improvable, but I can't immediately see how.
Explanation
’ÆRḊμ_Æp=2Tịμ_2;μİS
ÆR Generate all primes from 2 to n inclusive
’ Subtract 1
Ḋ Remove first element
’ÆRḊ Generate all primes from 3 to n-1 exclusive
_Æp Subtract the previous prime (i.e. calculate the prime gap)
=2 Compare to 2
Tị Take elements of the input where the comparison is true
_Æp=2Tị Filter a list of primes to the latter halves of prime pairs
_2 Subtract 2
; Append
_2; Append the list to the list with 2 subtracted from it
İ Take reciprocals
S Sum
İS Take the sum of the reciprocals
The μ connect all these portions together pipeline-style, with each taking the output of the one before as its input.
Jelly, 19 bytes
’ÆRḊμ_Æp=2Tịμ_2;μİS
I have a feeling that this is improvable, but I can't immediately see how.
Explanation to come.