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 Revisions

4 of 5
Commonmark migration

Constructible n-gons

A constructible n-gon is a regular polygon with n sides that you can construct with only a compass and an unmarked ruler.

As stated by Gauss, the only n for which a n-gon is constructible is a product of any number of distinct Fermat primes and a power of 2 (ie. n = 2^k * p1 * p2 * ... with k being an integer and every p some distinct Fermat prime).

A Fermat prime is a prime which can be expressed as F(n)=2^(2^n)+1 whith n a positive integer. The only known Fermat prime are for 0, 1, 2, 3 and 4.

The challenge

Given an integer n>2, say if the n-gon is constructible or not.

Specification

Your program or function should take an integer or a string representing said integer (either in unary, binary, decimal or any other base) and return or print a truthy or falsy value.

This is code-golf, so shortest answer wins, standard loopholes apply.

Relevant OEIS

Examples

3 -> True
9 -> False
17 -> True
1024 -> True
65537 -> True
67109888 -> True
67109889 -> False
Sefa
  • 580
  • 4
  • 20

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