Quick actions

cmd+k|ctrl+k

Navigation

Languages

Print all prime numbers up to given limit

Snippet info

Language

Python

Visibility

public

Author

codewithsoumik

Created

2024-11-20T10:57:15.542625Z

Updated

2024-11-20T10:57:15.542625Z

#let the limit be l
l = int(input("Enter the limit (integer):"))
#the function below checks if the function argument/parameter(n) is prime or not
def checkprime(n):
    count = 0
    for i in range(1,n+1):
        if n%i == 0:
            count+=1
    if count == 2:
        return 1
    else:
        return 0
print("The prime numbers upto",l)
for i in range(2,l+1):
    if checkprime(i) == 1:
        print(i)
INFO