Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # FUNCTION 1 - Finds if a number is prime
- def isPrime(n):
- for i in range(2, int(n/2)):
- if n % i == 0:
- return False
- return True
- # MAIN FUNCTION
- limit = 10**3
- for n in range(2, limit+1, 2):
- flag = isPrime(n**2 + 1)
- result = ""
- if flag:
- result = " is prime"
- else:
- result = " is not prime"
- print("n = " + str(n) + " ----> n^2 + 1 = " + str(n**2+1) + result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement