Program to find the nth Kynea number | CPP code to find nth Kynea number ; Function to calculate nth kynea number ; Firstly calculate 2 ^ n + 1 ; Now calculate ( 2 ^ n + 1 ) ^ 2 ; Now calculate ( ( 2 ^ n + 1 ) ^ 2 ) - 2 ; return nth Kynea number ; Driver Program ; print nth kynea number
#include <bits/stdc++.h> NEW_LINE using namespace std ; long nthKyneaNumber ( int n ) { n = ( 1 << n ) + 1 ; n = n * n ; n = n - 2 ; return n ; } int main ( ) { int n = 8 ; cout << nthKyneaNumber ( n ) ; return 0 ; }