diff --git a/algorithms/miscellaneous/sieveoferalothenes.py b/algorithms/miscellaneous/sieveoferalothenes.py new file mode 100644 index 00000000..19802cda --- /dev/null +++ b/algorithms/miscellaneous/sieveoferalothenes.py @@ -0,0 +1,13 @@ +#this progran will check for prime numbers to a certain range and if the prime is prime it will display True else False +import math +n=int(input("Enter the number")) +isPrime=[] +for i in range(n): + isPrime.append(True) #assigning the array to False uptil n +isPrime[0]=False +isPrime[1]=False +for i in range(2,int(math.sqrt(n)),1): + for j in range(2*i,n,i): #checking for prime numbers + isPrime[j]=False +for i in range(0,n,1): + print(i,":",isPrime[i]) \ No newline at end of file