Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

What's next, Achilles?

Powerful numbers are positive integers such that, when expressed as a prime factorisation:

$$a = p_1^{e_1} \times p_2^{e_2} \times p_3^{e_3} \cdots \times p_k^{e_k}$$

all exponents \$e_1, e_2, ...\$ are greater than or equal to \2ドル\$. Note that the exponents do not include zero exponents, as exampled by \200ドル = 2^3 \times 3^0\times 5^2 = 2^3 \times 5^2\$ being a powerful number. This includes all perfect powers, and a few "extra" numbers that are not perfect powers.

Achilles numbers are powerful numbers that are not perfect powers. The smallest Achilles number is \72ドル = 2^3 \times 3^2\$. The Achilles numbers less than or equal to \500ドル\$ are \72,ドル 108, 200, 288, 392, 432\$ and \500ドル\$.

You are to take an Achilles number as input and output the smallest Achilles number greater than the input.

You may input and output in any convenient method. This is so the shortest code in bytes wins

Test Cases

input output
 72 108
 108 200
 200 288
 800 864
 1152 1323
 4500 4563
 3456 3528
 4563 4608
43808 43904
90828 91592
28800 29403
64800 64827
29768 30375

The program I used to generate these test cases. Contains spoilers for anyone who can understand Jelly.

Answer*

Draft saved
Draft discarded
Cancel
4
  • 1
    \$\begingroup\$ Very clever use of filtering--even if it had occurred to me that I could count on the GCD being 1 if it matters to check if the number is powerful, I probably still wouldn't have come up with that. \$\endgroup\$ Commented Feb 23, 2021 at 13:37
  • \$\begingroup\$ If you’d like to save a byte on this almost three-year-old answer, you can replace f1Ʋ with ỊƊ: tio.run/#%23y0rNyan8//… \$\endgroup\$ Commented Oct 29, 2023 at 13:26
  • \$\begingroup\$ @NickKennedy that won't work even though it passes all the test cases. A counter-example would be an input of \2ドル^3 \times 5^4 = 5000\$ which should find \2ドル^2 \times 3^3 \times 7^2 = 5292\$ but will find \2ドル^6 \times 3^4 = 5184\$ because [2]Ị is [0] which is truthy. \$\endgroup\$ Commented Oct 29, 2023 at 18:31
  • 1
    \$\begingroup\$ Quite right. I thought I’d tested that but must have missed something! Nice solution by the way. \$\endgroup\$ Commented Oct 29, 2023 at 23:16

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