Tuesday, 13 February 2024

Class 11 CS Practical - 26

 

26 - Write a program in Python to to generate all prime numbers between 2 to 100.

print("Prime Number from 2 to 100: ")

for n in range(2,101):

    for i in range(2,n+1): 

        if (n%i==0): 

            break 

    if(n==i): 

        print(n,end=" ") 


Output:

Prime Number from 2 to 100:

2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97


No comments:

Post a Comment