Suppose we have an angle a. We have to check whether we can make a regular polygon where all angles are same as a or not.
So, if the input is like a = 120, then the output will be True the pentagon has all angles same as 120°. As we know
$$Interior Angle(a)=\frac{180\times(n-2)}{n}\begin{bmatrix} n=number of sides of polygon\end{bmatrix}$$ $$¿n=\frac{360}{180-a}$$
So if n is integer then this is forming a regular polygon.
To solve this, we will follow these steps −
- sides := 360 /(180 - a)
- if sides has no fractional part, then
- return True
- return False
Example
Let us see the following implementation to get better understanding −
def solve(a) : sides = 360 / (180 - a) if sides == int(sides) : return True return False a = 120 print (solve(a))
Input
120
Output
True