I am to find if any given angle(say x)can be interior angle of regular polygon.In other words,is there a regular polygon which angles are equal to X.

I know the formula for sum of interior angles of polygon i.e (n-2)*180. I tried looping from sides 3 to 10000 and pushing back ((n-2)*180)/n and after this pre-computation i tried searching each given angles.Please see code if not clear

#include <bits/stdc++.h>
using namespace std;
int main() {
 // your code goes here
  int t;
  for(int i=3;i<=1000;i++)
     int a;
   return 0;

This is giving correct answer for some values but not all.

Is there any better(geometrical way) to do this ?


I have seen the solution and it was something like true if (360%(180-x)==0) else false.I still can't get it(why 360%(180-x).Anybody please explain this or give different way

  • $\begingroup$ v.push_back(((180)*(i-2))/(i)); should be v.push_back(((180)*(i-2))/double(i)); $\endgroup$ May 1, 2015 at 3:45
  • $\begingroup$ Why double MR@AlexeyBurdin .Well even after type cating it is not giving correct answer. $\endgroup$ May 1, 2015 at 3:53
  • $\begingroup$ So the problem is "Determine if there is a regular polygon with interior angle strictly equal to that given integer degrees"? $\endgroup$ May 1, 2015 at 4:22
  • $\begingroup$ possibly i am not clear enough.You can see this sir,codeforces.com/problemset/problem/270/A $\endgroup$ May 1, 2015 at 4:25

1 Answer 1


Let $A,B$ be the consecutive vertices of a regular $n$-vertices polygon and $O$ be it's center.
$\angle AOB=\frac{360^{\circ}}{n}$, $\Delta AOB$ is isosceles, so $\angle OAB = \frac{180^{\circ} - \angle AOB}{2}$ and the interior angle $=2\angle OAB = x^{\circ}$ and $x$ is integer.
We are to find whether it could be an integer $n$ that gives that $x$.
$$180-\frac{360}{n}=x$$ $$\frac{360}{n}=180-x$$ $$n=\frac{360}{180-x}$$ So puts(360%(180-x)?"NO":"YES") should work. :)

  • 1
    $\begingroup$ Wow....thanks a lot!!!! $\endgroup$ May 1, 2015 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.