Jelly, (削除) 14 (削除ここまで) 13 bytes
-1 thanks to ChartZBelatedly! (use the built-in for choose-2.)
Thanks to Delfad0r for the simple explanation in their Haskell answer proving that this works, I probably would not have posted it otherwise!
ÆRPƤ‘Æn_ƊŒc§ċ
A monadic Link accepting an integer \$n\$ that yields a positive integer if \$n\$ is a Fortunate Sum, or zero if not.
Try it online! Or see A split of \$n\leq 100\$ into non-Fortunate and Fortunate Sums.
How?
ÆRPƤ‘Æn_ƊŒc§ċ - Link: integer, n e.g. 18
ÆR - primes between 2 and n inclusive [2,3, 5, 7, 11, 13, 17]
Ƥ - for prefixes:
P - product [2,6 ,30,210,2310,30030,510510]
Ɗ - last three links as a monad, f(x=that):
‘ - increment (x) [3,7 ,31,211,2311,30031,510511]
Æn - next, strictly greater, prime [5,11,37,223,2333,30047,510529]
_ - subtract (x) [3,5, 7, 13, 23, 17, 19]
Œc - choose-2 [[3,5],[3,7],[3,13],[3,23],[3,17],[3,19],[5,7],[5,13],[5,23],[5,17],[5,19],[7,13],[7,23],[7,17],[7,19],[13,23],[13,17],[13,19],[23,17],[23,19],[17,19]]
§ - sums [8,10,16,26,20,22,12,18,28,22,24,20,30,24,26,36,30,32,40,42,36]
ċ - count occurrences (of n) 1 (truthy)
Jonathan Allan
- 115.4k
- 8
- 68
- 293