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

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Actually, 6 bytes

This answer is based on xnor's algorithm in Martin Ender's Jelly answer xnor's algorithm in Martin Ender's Jelly answer. Golfing suggestions welcome. Try it online!

▒D├♂≈π

How it works

 Implicit input n.
▒ totient(n)
 D Decrement.
 ├ Convert to binary (as string).
 ♂≈ Convert each char into an int.
 π Take the product of those binary digits.
 If the result is 1,
 then bin(totient(n) - 1) is a string of 1s, and totient(n) is power of two.

Actually, 6 bytes

This answer is based on xnor's algorithm in Martin Ender's Jelly answer. Golfing suggestions welcome. Try it online!

▒D├♂≈π

How it works

 Implicit input n.
▒ totient(n)
 D Decrement.
 ├ Convert to binary (as string).
 ♂≈ Convert each char into an int.
 π Take the product of those binary digits.
 If the result is 1,
 then bin(totient(n) - 1) is a string of 1s, and totient(n) is power of two.

Actually, 6 bytes

This answer is based on xnor's algorithm in Martin Ender's Jelly answer. Golfing suggestions welcome. Try it online!

▒D├♂≈π

How it works

 Implicit input n.
▒ totient(n)
 D Decrement.
 ├ Convert to binary (as string).
 ♂≈ Convert each char into an int.
 π Take the product of those binary digits.
 If the result is 1,
 then bin(totient(n) - 1) is a string of 1s, and totient(n) is power of two.
Source Link
Sherlock9
  • 12.4k
  • 1
  • 31
  • 68

Actually, 6 bytes

This answer is based on xnor's algorithm in Martin Ender's Jelly answer. Golfing suggestions welcome. Try it online!

▒D├♂≈π

How it works

 Implicit input n.
▒ totient(n)
 D Decrement.
 ├ Convert to binary (as string).
 ♂≈ Convert each char into an int.
 π Take the product of those binary digits.
 If the result is 1,
 then bin(totient(n) - 1) is a string of 1s, and totient(n) is power of two.

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