{"id":18988,"date":"2021-08-29T15:13:06","date_gmt":"2021-08-29T09:43:06","guid":{"rendered":"https:\/\/python-programs.com\/?p=18988"},"modified":"2021-11-22T18:37:09","modified_gmt":"2021-11-22T13:07:09","slug":"python-program-to-find-next-prime-number","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-find-next-prime-number\/","title":{"rendered":"Python Program to Find Next Prime Number"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Compute the Perimeter of Trapezoid<\/a>
\nItertools count() function:<\/strong><\/p>\n

The count(start, step) method generates an iterator that is used to generate equally spaced numbers, where the step argument defines the space between them. The start argument specifies the iterator’s starting value, which is set by default to start=0 and step=1.<\/p>\n

In the absence of a breaking condition, the count() method will continue counting indefinitely (on a system with infinite memory)<\/p>\n

Given a number N, the task is to print the next prime number in Python.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number =48<\/pre>\n

Output:<\/strong><\/p>\n

The Next prime number of { 48 } is: 53<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given Number =75<\/pre>\n

Output:<\/strong><\/p>\n

The Next prime number of { 75 } is: 79<\/pre>\n

Program to Find next Prime Number in Python<\/h2>\n

Below are the ways to print the next prime number in Python:<\/p>\n