Generates M prime numbers

Programe is:
# Generates M prime numbers, M > 1
M = int(input('Number of prime numbers  are:'))
print ('Prime numbers list is:')
print (1,  '  ')
print (2,  '  ')
print (3,  '  ')
# MM = M 
K = 1
N = 3
while K <= M:
    A = N**0.5
    B = int(A)
    C = False
    D = 2
    while (C == False) and (D <= B):
        if(N % D) == 0:
            C = True
        D = D + 1
    if (C == False):
        print ( N,  '  ')
    N = N + 2
    K = K + 1
print ('The list was successfully printed')

Results are: 

Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
========= RESTART: /Users/ionivan/Documents/GenerareListaNumerePrime.py ========
Number of prime numbers  are:10
Prime numbers list is:
1   
2   
3   
3   
5   
7   
11   
13   
17   
19   
The list was successfully printed

(March 21, 2022) 

Comments

Popular posts from this blog

Pointers in PYTHON?