Continuous prime number

Mass calculated for several

description

Supplementary programming template code, the following functions:

Obtaining user input number N, calculates and outputs the five prime numbers starting from N, single line output, with commas between the prime number divided.

note:

The user input may be a floating point number N are positive; no comma after the last output.

Code

import math


def prime(m):
    a = []
    num = math.ceil(m)
    while len(a) < 5:
        for i in range(2, num):
            if num % i == 0:
                num = num + 1
                break
            else:
                if i == num - 1:
                    a.append(str(num))
                    num = num + 1
    return a


n = eval(input())
w = prime(n)
print(','.join(w))

Guess you like

Origin www.cnblogs.com/xiaoxuesheng993/p/10956637.html