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

deleted 14 characters in body
Source Link
FlipTack
  • 14.7k
  • 3
  • 56
  • 102

Pushy, 7 bytes

oBoIpP#

Try it online!

This takes advantage of the fact that mersenne numbers have only ones in their binary representation:

oB \ Pop input, push its binary digits.
 oI \ Re-push the input
 p \ Test its primality (0/1)
 P# \ Print the product of the stack

The stack product will only be 1 if the number has no zeroes in its binary representation, and its primality evaluates tois 1True (True).

Pushy, 7 bytes

oBoIpP#

Try it online!

This takes advantage of the fact that mersenne numbers have only ones in their binary representation:

oB \ Pop input, push its binary digits.
 oI \ Re-push the input
 p \ Test its primality (0/1)
 P# \ Print the product of the stack

The stack product will only be 1 if the number has no zeroes in its binary representation, and its primality evaluates to 1 (True).

Pushy, 7 bytes

oBoIpP#

Try it online!

This takes advantage of the fact that mersenne numbers have only ones in their binary representation:

oB \ Pop input, push its binary digits.
 oI \ Re-push the input
 p \ Test its primality (0/1)
 P# \ Print the product of the stack

The stack product will only be 1 if the number has no zeroes in its binary representation, and its primality is True.

Source Link
FlipTack
  • 14.7k
  • 3
  • 56
  • 102

Pushy, 7 bytes

oBoIpP#

Try it online!

This takes advantage of the fact that mersenne numbers have only ones in their binary representation:

oB \ Pop input, push its binary digits.
 oI \ Re-push the input
 p \ Test its primality (0/1)
 P# \ Print the product of the stack

The stack product will only be 1 if the number has no zeroes in its binary representation, and its primality evaluates to 1 (True).

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