Count of nested polygons that can be drawn by joining vertices internally | C ++ program for the above approach ; Function that counts the nested polygons inside another polygons ; Stores the count ; Child polygons can only existss if parent polygon has sides > 5 ; Get next nested polygon ; Return the count ; Driver Code ; Given side of polygon ; Function Call
#include <iostream> NEW_LINE using namespace std ; int countNestedPolygons ( int sides ) { int count = 0 ; while ( sides > 5 ) { sides /= 2 ; count += 1 ; } return count ; } int main ( ) { int N = 12 ; cout << countNestedPolygons ( N ) ; return 0 ; }