##Jelly, 5 bytes
Jelly, 5 bytes
Alternate approach to @Dennis' existing 5-byte Jelly answer:
B;ÆPP
How it works:
B Returns the binary representation of the input as a list [1, 0, 1, 1, ...]
; And attach to this list
ÆP a 1 if the input is a prime, 0 otherwise
P Calculates the product of this list of 1's and 0's
Since a Mersenne Prime is one less than a power of 2, its binary representation is excusively 1's. The output therefor is 1 for Mersenne primes, and 0 in all other cases .
##Jelly, 5 bytes
Alternate approach to @Dennis' existing 5-byte Jelly answer:
B;ÆPP
How it works:
B Returns the binary representation of the input as a list [1, 0, 1, 1, ...]
; And attach to this list
ÆP a 1 if the input is a prime, 0 otherwise
P Calculates the product of this list of 1's and 0's
Since a Mersenne Prime is one less than a power of 2, its binary representation is excusively 1's. The output therefor is 1 for Mersenne primes, and 0 in all other cases .
Jelly, 5 bytes
Alternate approach to @Dennis' existing 5-byte Jelly answer:
B;ÆPP
How it works:
B Returns the binary representation of the input as a list [1, 0, 1, 1, ...]
; And attach to this list
ÆP a 1 if the input is a prime, 0 otherwise
P Calculates the product of this list of 1's and 0's
Since a Mersenne Prime is one less than a power of 2, its binary representation is excusively 1's. The output therefor is 1 for Mersenne primes, and 0 in all other cases .
##Jelly, 5 bytes
Alternate approach to @Dennis' existing 5-byte Jelly answer:
B;ÆPP
How it works:
ÆP Returns 1 if the input is a prime, 0 otherwise
B Returns the binary representation of the input as a list [1, 0, 1, 1, ...]
; And attach to this list
ÆP a 1 if the input is a prime, 0 otherwise
P Calculates the product of this list of 1's and 0's
Since a Mersenne Prime is one less than a power of 2, its binary representation is excusively 1's. The output therefor is 1 for Mersenne primes, and 0 in all other cases .
##Jelly, 5 bytes
Alternate approach to @Dennis' existing 5-byte Jelly answer:
B;ÆPP
How it works:
ÆP Returns 1 if the input is a prime, 0 otherwise
B Returns the binary representation of the input as a list [1, 0, 1, 1, ...]
; And attach to this list
ÆP a 1 if the input is a prime, 0 otherwise
P Calculates the product of this list of 1's and 0's
Since a Mersenne Prime is one less than a power of 2, its binary representation is excusively 1's. The output therefor is 1 for Mersenne primes, and 0 in all other cases .
##Jelly, 5 bytes
Alternate approach to @Dennis' existing 5-byte Jelly answer:
B;ÆPP
How it works:
B Returns the binary representation of the input as a list [1, 0, 1, 1, ...]
; And attach to this list
ÆP a 1 if the input is a prime, 0 otherwise
P Calculates the product of this list of 1's and 0's
Since a Mersenne Prime is one less than a power of 2, its binary representation is excusively 1's. The output therefor is 1 for Mersenne primes, and 0 in all other cases .
##Jelly, 5 bytes
Alternate approach to @Dennis' existing 5-byte Jelly answer:
ÆP&BPB;ÆPP
How it works:
ÆP Returns 1 if the input is a prime, 0 otherwise
B B Returns the binary representation of the input as a list [1, 0, 1, 1, ...]
; P Calculates theAnd productattach ofto thatthis list of 1's and 0's
ÆP Since a Mersenne Prime1 isif onethe lessinput thanis a power of 2prime, its binary representation
is excusively 1's. The product is0 1.otherwise
& P BitwiseCalculates ANDthe -product yieldsof 1this onlylist ifof left1's and right also yield 1.0's
Since a Mersenne Prime is one less than a power of 2, its binary representation is excusively 1's. The output therefor is 1 for Mersenne primes, and 0 in all other cases .
##Jelly, 5 bytes
Alternate approach to @Dennis' existing 5-byte Jelly answer:
ÆP&BP
How it works:
ÆP Returns 1 if the input is a prime, 0 otherwise
B Returns the binary representation of the input as a list [1, 0, 1, 1, ...]
P Calculates the product of that list of 1's and 0's
Since a Mersenne Prime is one less than a power of 2, its binary representation
is excusively 1's. The product is 1.
& Bitwise AND - yields 1 only if left and right also yield 1.
##Jelly, 5 bytes
Alternate approach to @Dennis' existing 5-byte Jelly answer:
B;ÆPP
How it works:
ÆP Returns 1 if the input is a prime, 0 otherwise
B Returns the binary representation of the input as a list [1, 0, 1, 1, ...]
; And attach to this list
ÆP a 1 if the input is a prime, 0 otherwise
P Calculates the product of this list of 1's and 0's
Since a Mersenne Prime is one less than a power of 2, its binary representation is excusively 1's. The output therefor is 1 for Mersenne primes, and 0 in all other cases .