Posts

Showing posts with the label prime numbers

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...