{"id":12499,"date":"2021-09-30T17:00:42","date_gmt":"2021-09-30T11:30:42","guid":{"rendered":"https:\/\/python-programs.com\/?p=12499"},"modified":"2021-11-22T18:33:33","modified_gmt":"2021-11-22T13:03:33","slug":"python-program-to-find-the-nth-kynea-number","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-the-nth-kynea-number\/","title":{"rendered":"Python Program to find the nth Kynea Number"},"content":{"rendered":"
Don’t miss the chance of Java programs examples with output pdf free download<\/a> as it is very essential for all beginners to experienced programmers for cracking the interviews.<\/p>\n Given the number n, the task is to print nth Kynea Number in Python.<\/p>\n Kynea number is a mathematical integer of the type<\/p>\n nth = 4^n + 2^(n + 1) – 1, where n is a positive integer.<\/p>\n Which can be also written as<\/p>\n \u00a0 <\/p><\/blockquote>\n The initial Kynea numbers are<\/p>\n 7, 23, 79, 287, 1087, 4223, 16639,…………..<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Below are the ways to program to find the nth Kynea Number.<\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Related Programs<\/strong>:<\/p>\n Don’t miss the chance of Java programs examples with output pdf free download as it is very essential for all beginners to experienced programmers for cracking the interviews. Given the number n, the task is to print nth Kynea Number in Python. Kynea number is a mathematical integer of the type nth = 4^n + …<\/p>\nGiven nth number =6<\/pre>\n
The nth Kynea number = 4223<\/pre>\n
Given nth number =8<\/pre>\n
The nth Kynea number = 66047<\/pre>\n
Python Program to find the nth Kynea Number<\/h2>\n
\n
Method #1: Using ** operator (Static Input)<\/h3>\n
\n
# Give the number n as static input and store it in a variable.\r\nnthNum = 6\r\n# Calculate the power of 2^n using the ** operator\r\n# and store it in another variable say partialres.\r\npartialres = 2**nthNum\r\n# Calculate the value of (partialres+1)^2-2\u00a0\r\n# using ** and arithmetic operators.\r\nnthresult = (partialres+1)**2-2\r\n# Print the result.\r\nprint('The nth Kynea number =', nthresult)\r\n<\/pre>\n
The nth Kynea number = 4223<\/pre>\n
Method #2: Using ** operator (User Input)<\/h3>\n
\n
# Give the number n as user input using int(input()) and store it in a variable.\r\nnthNum = int(input('Enter some random nth Number = '))\r\n# Calculate the power of 2^n using the ** operator\r\n# and store it in another variable say partialres.\r\npartialres = 2**nthNum\r\n# Calculate the value of (partialres+1)^2-2\u00a0\r\n# using ** and arithmetic operators.\r\nnthresult = (partialres+1)**2-2\r\n# Print the result.\r\nprint('The nth Kynea number =', nthresult)\r\n<\/pre>\n
Enter some random nth Number = 9\r\nThe nth Kynea number = 263167<\/pre>\n
Method #3: Using pow operator (Static Input)<\/h3>\n
\n
# Give the number n as static input and store it in a variable.\r\nnthNum = 6\r\n# Calculate the power of 2^n using the pow function\r\n# and store it in another variable say partialres.\r\npartialres = 2**nthNum\r\n# Calculate the value of (partialres+1)^2-2\u00a0\r\n# using pow function and arithmetic operators.\r\nnthresult = (partialres+1)**2-2\r\n# Print the result.\r\nprint('The nth Kynea number =', nthresult)\r\n<\/pre>\n
The nth Kynea number = 4223<\/pre>\n
Method #4: Using pow operator (User Input)<\/h3>\n
\n
# Give the number n as user input using int(input()) and store it in a variable.\r\nnthNum = int(input('Enter some random nth Number = '))\r\n# Calculate the power of 2^n using the pow function\r\n# and store it in another variable say partialres.\r\npartialres = 2**nthNum\r\n# Calculate the value of (partialres+1)^2-2\u00a0\r\n# using pow function and arithmetic operators.\r\nnthresult = (partialres+1)**2-2\r\n# Print the result.\r\nprint('The nth Kynea number =', nthresult)\r\n<\/pre>\n
Enter some random nth Number = 8\r\nThe nth Kynea number = 66047<\/pre>\n
\n