Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

I ain't no Fortunate sum

The primorial \$p_n\#\$ is the product of the first \$n\$ primes. The sequence begins \2,ドル 6, 30, 210, 2310\$.

A Fortunate number, \$F_n\$, is the smallest integer \$m > 1\$ such that \$p_n\# + m\$ is prime. For example \$F_7 = 19\$ as:

$$p_7\# = 2\times3\times5\times7\times11\times13\times17 = 510510$$

Adding each number between \2ドル\$ and \18ドル\$ to \510510ドル\$ all yield composite numbers. However, \510510ドル + 19 = 510529\$ which is prime.

The Fortunate numbers below \200ドル\$ are

$3,ドル 5, 7, 13, 17, 19, 23, 37, 47, 59, 61, 67, 71, 79, 89, 101, 103, 107, 109, 127, 151, 157, 163, 167, 191, 197, 199$$

We'll say an integer \$n\$ is a "Fortunate sum" if it can be expressed as the sum of two distinct Fortunate numbers. For example, \22ドル = 3 + 19 = 5 + 17\$, so \22ドル\$ can be expressed as the sum of two Fortunate numbers, and so is a "Fortunate sum"

You are to take an integer \$n\$ as input and output a truthy value if \$n\$ is a Fortunate sum and a falsey value otherwise. You may swap the order (falsey indicates it is a Fortunate sum) if you wish. You may take input and output in any convenient format.

This is so the shortest code in bytes wins

Test cases

The first line is the Fortunate sums less than 100 (truthy values) and the second are the integers less than or equal to 100 that aren't Fortunate sums

8 10 12 16 18 20 22 24 26 28 30 32 36 40 42 44 50 52 54 56 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98
1 2 3 4 5 6 7 9 11 13 14 15 17 19 21 23 25 27 29 31 33 34 35 37 38 39 41 43 45 46 47 48 49 51 53 55 57 58 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 100

Answer*

Draft saved
Draft discarded
Cancel
5
  • 1
    \$\begingroup\$ œc2 can be Œc \$\endgroup\$ Commented Mar 16, 2021 at 21:18
  • \$\begingroup\$ Ah yeah, thanks for that @ChartZBelatedly! \$\endgroup\$ Commented Mar 16, 2021 at 21:19
  • \$\begingroup\$ I lost the link to my 17 byte version, and I'm trying to remember how it wasn't this, because aside from me using ×\ instead of and i instead of ċ, this is exactly what I remember mine being :/ \$\endgroup\$ Commented Mar 16, 2021 at 21:29
  • \$\begingroup\$ Odd, maybe you mistakenly counted what would be a footer to give either one or both of the two sets below 100? \$\endgroup\$ Commented Mar 16, 2021 at 21:31
  • \$\begingroup\$ Quite possibly. Guess we'll never know though :/ +1 for outgolfing me :) \$\endgroup\$ Commented Mar 16, 2021 at 21:33

AltStyle によって変換されたページ (->オリジナル) /