Newmanâ €“ Shanksâ €“ Williams prime | Java Program to find Newman - Shanks - Williams prime ; return nth Newman - Shanks - Williams prime ; Base case ; Recursive step ; Driver code
class GFG { static int nswp ( int n ) { if ( n == 0 n == 1 ) return 1 ; return 2 * nswp ( n - 1 ) + nswp ( n - 2 ) ; } public static void main ( String [ ] args ) { int n = 3 ; System . out . println ( nswp ( n ) ) ; } }