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

Return to Answer

added 1 character in body
Source Link
Sean
  • 8.2k
  • 12
  • 16

Raku, 41 bytes

{grep {is-prime $_&2*$_+1&$_/2-.5},1..$_}

Try it online!

This filters (greps) the numbers from 1 to the input argument to those where the conjunction (&) of the number ($_), twice that number plus one (2 * $_ + 1) and half the number minus one half ($_ / 2 - .5) is prime. Th The conjunction is prime if all of its elements are.

Raku, 41 bytes

{grep {is-prime $_&2*$_+1&$_/2-.5},1..$_}

Try it online!

This filters (greps) the numbers from 1 to the input argument to those where the conjunction (&) of the number ($_), twice that number plus one (2 * $_ + 1) and half the number minus one half ($_ / 2 - .5) is prime. Th conjunction is prime if all of its elements are.

Raku, 41 bytes

{grep {is-prime $_&2*$_+1&$_/2-.5},1..$_}

Try it online!

This filters (greps) the numbers from 1 to the input argument to those where the conjunction (&) of the number ($_), twice that number plus one (2 * $_ + 1) and half the number minus one half ($_ / 2 - .5) is prime. The conjunction is prime if all of its elements are.

Source Link
Sean
  • 8.2k
  • 12
  • 16

Raku, 41 bytes

{grep {is-prime $_&2*$_+1&$_/2-.5},1..$_}

Try it online!

This filters (greps) the numbers from 1 to the input argument to those where the conjunction (&) of the number ($_), twice that number plus one (2 * $_ + 1) and half the number minus one half ($_ / 2 - .5) is prime. Th conjunction is prime if all of its elements are.

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