Given an integer N which is the number of sides of a regular polygon. The task is to find the smallest angle of rotation such that the generated regular polygons have a similar position and dimensions, i.e. the new rotated polygon is in symmetry with the initial one.
A shape is said to have a rotation symmetry if there exists a rotation in the range [1, 360o] such that the new shape overlaps the initial shape completely.
Input: N = 4
A 4 sided regular polygon is a square and when it is rotated by 90 degrees it results in the similar square.
Input: N = 8
Approach: For any N sided regular polygon, when rotated by 360 degrees, it aligns in the original position of the polygon. To find the minimum angle of rotation we use the property of symmetry of regular polygons. For an N sided regular polygon when rotated by 360/N degrees, the rotated polygon is in the same position as of the original polygon, which is the exterior angle of an N-sided regular polygon.
Consider N = 4,
Below is the implementation of the above approach.
Angle of Rotational Symmetry: 90
Time Complexity: O (1)
Auxiliary Space: O (1)
Attention reader! Don’t stop learning now. Get hold of all the important mathematical concepts for competitive programming with the Essential Maths for CP Course at a student-friendly price. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.