Write a Python script to test whether the following numbers areprime using the 101prime.txt file.
2692493
2692503
4632703
8767843
7982119
7983121
13065521
11505341
11505343
14123649
14123651
Solution
import math
# reading file
f = open(“101prime.txt”).read().split()
# considering each number
for one in f:
n = int(one)
# checking if it is prime
isPrime = True
for i in range(2, int(math.sqrt(n))+1):
if n%i == 0:
isPrime = False
break
# printing if it is primme
if isPrime:
print(n)
————————————–
Hit the thumbs up if you are fine with the answer. HappyLearning!
2692493 4632703 7983121 11505341 11505343 mport math # reading file f-open(“101prime.txt”).read().split() # considering each number for one in f: n-int (one)
OR
OR