![]() |
VOOZH | about |
Given the number of sides 'n' and the length of side 's' of a regular polygon, the task is to find out the Perimeter of this polygon.
Examples:
Input: n = 7, s = 10 Output: Perimeter : 70 Since the sides are 7, Hence the given polygon is Heptagon. Therefore. Perimeter = 7*10 = 70 Input: n = 5, s = 2.5 Output: Perimeter : 12.5 Since the sides are 5, Hence the given polygon is Pentagon. Therefore. Perimeter = 5*2.5 = 12.5
Approach: In geometry, a regular polygon is a closed figure with all sides equal. It is a two-dimensional figure.
Perimeter of a Regular Polygon = Number of sides * Length of each side
Below is the implementation of the above approach:
Perimeter of Regular Polygon with 5 sides of length 2.500000 = 12.500000
Time Complexity: O(1), since there is no loop or recursion.
Auxiliary Space: O(1), since no extra space has been taken.