Monday, 14 March 2022

Prime Problem !!!

 PROBLEM 45: Prime 


Program to find out all the prime numbers from the range of 0 to n. 


 Name - Ajay Zad

 Date - 14/03/2022 


n = int(input("Enter the value for n :"))

cnt = 0 

print("The Prime numbers are :")

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

    for j in range(2,i):

        if i % j == 0:   

            cnt = cnt + 1

        

    if cnt == 0:

        print(i)

    cnt = 0




Input:

Enter the value for n : 

10


Output :

The Prime numbers are :

2

3

5

7

No comments:

Post a Comment

Rearrange an array with O(1) extra space

  PROBLEM 61:  Rearrange an array with O(1) extra space (For best view experience, view in windows version) Problem Reference : GeeksForGeek...