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 758 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 12 bytes

‘ÆEg/ḟ$f1Ʋ1#

A full program which prints the next Achilles number.

Try it online! Or see the test-suite.

How?

‘ÆEg/ḟ$f1Ʋ1# - Main Link: Archiles number (or any integer), n
‘ - increment (n)
 1# - find the first k (starting at k=n+1) for which:
 Ʋ - last four links as a monad - i.e. f(k):
 ÆE - prime exponent vactor (e.g k=400 -> [3,0,2] since 2^3+3^0+5^2)
 $ - last two links as a monad:
 / - reduce by:
 g - Greatest Common Divisor -> x
 ḟ - filter discard (from [x] if in ÆE result)
 1 - one
 f - filter keep (i.e. [1] if g/ was 1 and 1 not in ÆE result)
 (empty list is falsey, so we keep incrementing k until we get [1])

Jelly, 12 bytes

‘ÆEg/ḟ$f1Ʋ1#

A full program which prints the next Achilles number.

Try it online! Or see the test-suite.

Jelly, 12 bytes

‘ÆEg/ḟ$f1Ʋ1#

A full program which prints the next Achilles number.

Try it online! Or see the test-suite.

How?

‘ÆEg/ḟ$f1Ʋ1# - Main Link: Archiles number (or any integer), n
‘ - increment (n)
 1# - find the first k (starting at k=n+1) for which:
 Ʋ - last four links as a monad - i.e. f(k):
 ÆE - prime exponent vactor (e.g k=400 -> [3,0,2] since 2^3+3^0+5^2)
 $ - last two links as a monad:
 / - reduce by:
 g - Greatest Common Divisor -> x
 ḟ - filter discard (from [x] if in ÆE result)
 1 - one
 f - filter keep (i.e. [1] if g/ was 1 and 1 not in ÆE result)
 (empty list is falsey, so we keep incrementing k until we get [1])
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 12 bytes

‘ÆEg/ḟ$f1Ʋ1#

A full program which prints the next Achilles number.

Try it online! Or see the test-suite.

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