Newman Shanks Williams prime | CPP Program to find Newman Shanks Williams prime ; return nth Newman Shanks Williams prime ; Base case ; Finding nth Newman Shanks Williams prime ; Driver Program
#include <bits/stdc++.h> NEW_LINE using namespace std ; int nswp ( int n ) { int dp [ n + 1 ] ; dp [ 0 ] = dp [ 1 ] = 1 ; for ( int i = 2 ; i <= n ; i ++ ) dp [ i ] = 2 * dp [ i - 1 ] + dp [ i - 2 ] ; return dp [ n ] ; } int main ( ) { int n = 3 ; cout << nswp ( n ) << endl ; return 0 ; }