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 252 characters in body
Source Link
Jonah
  • 34.1k
  • 4
  • 41
  • 95

J, 1313 7 bytes

[:*/p_&q:@i.@#^]inv

Try it online! Try it online!

  • p:@i.@# By itself, p: n returns the nth prime number, and # returns the length of a list. So this phrase returns the first l primes, where l is the input length.
  • ^] Raised to the input elementwise.
  • [:*/ Product of that list.

As described here , the verb _ q: n returns the prime exponents of n. So the inverse inv of that verb is exactly what we want.

J, 13 bytes

[:*/p:@i.@#^]

Try it online!

  • p:@i.@# By itself, p: n returns the nth prime number, and # returns the length of a list. So this phrase returns the first l primes, where l is the input length.
  • ^] Raised to the input elementwise.
  • [:*/ Product of that list.

J, 13 7 bytes

_&q:inv

Try it online!

As described here , the verb _ q: n returns the prime exponents of n. So the inverse inv of that verb is exactly what we want.

Source Link
Jonah
  • 34.1k
  • 4
  • 41
  • 95

J, 13 bytes

[:*/p:@i.@#^]

Try it online!

  • p:@i.@# By itself, p: n returns the nth prime number, and # returns the length of a list. So this phrase returns the first l primes, where l is the input length.
  • ^] Raised to the input elementwise.
  • [:*/ Product of that list.

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