Find the length of Kth N | Python3 program for the above approach ; Function to calculate the interior angle of a N - sided regular polygon ; Function to find the K - th polygon formed inside the ( K - 1 ) th polygon ; Stores the interior angle ; Stores the side length of K - th regular polygon ; Return the length ; Driver Code
import math NEW_LINE PI = 3.14159265 NEW_LINE def findInteriorAngle ( n ) : NEW_LINE INDENT return ( n - 2 ) * PI / n NEW_LINE DEDENT def calculateSideLength ( L , N , K ) : NEW_LINE INDENT angle = findInteriorAngle ( N ) NEW_LINE length = L * pow ( math . sin ( angle / 2 ) , ( K - 1 ) ) NEW_LINE return length NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 5 NEW_LINE L = 21 NEW_LINE K = 7 NEW_LINE print ( calculateSideLength ( L , N , K ) ) NEW_LINE DEDENT