Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Function 1 - isPrime
- def isPrime(n):
- if n != int(n) or n <= 1:
- print("Error while using function '" + isPrime.__name__ + "'")
- return -1000
- if n == 1 or n == 2:
- return True
- for i in range(2, int(n/2)):
- if n % i == 0:
- return False
- return True
- # Function 2 - Create pentada
- def createPentada(n):
- if n % 10 != 0:
- print("Error while using function '" + isPrime.__name__ + "'")
- return -1000
- return [n+1, n+3, n+5, n+7, n+9]
- # Function 3 - Solve
- def solve(LIMIT):
- for n in range(0, LIMIT, 10):
- pentada = createPentada(n)
- hits = 0
- for x in pentada:
- flag2 = isPrime(x)
- if flag2 == True:
- hits += 1
- else:
- print("Number that breaks the sequence = " + str(x))
- break
- if hits == 5:
- return pentada
- # MAIN FUNCTION
- LIMIT = 10**5
- print(solve(LIMIT))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement