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 263 characters in body
Source Link
Fatalize
  • 39.6k
  • 5
  • 73
  • 165

Brachylog, 24 bytes

;2^(|↰mGl~l×ばつ

Try it online!

Surely there are shorter ways to generate a list of primes...

Brachylog is based on SWI-Prolog and can deal with arbitrarily large integers , but this will quickly run out of memory for even simple lists.

Explanation

;2^( Output = 2^Input
 | Or (if the input is not an integer)
 ↰mG Recursive call of this predicate for all elements of the Input; call the result G
 Gl~l Take a list with as many elements as G
 N3mṗm≠≜ It must be a list of primes greater than 3 and all different (it always unifies with increasing magnitudes)
 ;Gz Zip with G
 ^m Map power
 ×ばつ Multiply

Brachylog, 24 bytes

;2^(|↰mGl~l×ばつ

Try it online!

Surely there are shorter ways to generate a list of primes...

Explanation

;2^( Output = 2^Input
 | Or (if the input is not an integer)
 ↰mG Recursive call of this predicate for all elements of the Input; call the result G
 Gl~l Take a list with as many elements as G
 N3mṗm≠≜ It must be a list of primes greater than 3 and all different (it always unifies with increasing magnitudes)
 ;Gz Zip with G
 ^m Map power
 ×ばつ Multiply

Brachylog, 24 bytes

;2^(|↰mGl~l×ばつ

Try it online!

Surely there are shorter ways to generate a list of primes...

Brachylog is based on SWI-Prolog and can deal with arbitrarily large integers , but this will quickly run out of memory for even simple lists.

Explanation

;2^( Output = 2^Input
 | Or (if the input is not an integer)
 ↰mG Recursive call of this predicate for all elements of the Input; call the result G
 Gl~l Take a list with as many elements as G
 N3mṗm≠≜ It must be a list of primes greater than 3 and all different (it always unifies with increasing magnitudes)
 ;Gz Zip with G
 ^m Map power
 ×ばつ Multiply
Source Link
Fatalize
  • 39.6k
  • 5
  • 73
  • 165

Brachylog, 24 bytes

;2^(|↰mGl~l×ばつ

Try it online!

Surely there are shorter ways to generate a list of primes...

Explanation

;2^( Output = 2^Input
 | Or (if the input is not an integer)
 ↰mG Recursive call of this predicate for all elements of the Input; call the result G
 Gl~l Take a list with as many elements as G
 N3mṗm≠≜ It must be a list of primes greater than 3 and all different (it always unifies with increasing magnitudes)
 ;Gz Zip with G
 ^m Map power
 ×ばつ Multiply

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