This is a Number Theory problem. My professor wants us to use Python coding to a
ID: 3744810 • Letter: T
Question
This is a Number Theory problem.My professor wants us to use Python coding to answer. I have got a little bit of the coding down, but it would be greatly appreciated if I could get some extra help! Coding Exercise. (1) The year 2017 had the following property: 2017 is prime, 2018 is two times a prime number (2018 2 1009), and p + 2 is three times a prime number (2019-3 673). Call such a year a triple prime year. Find five triple prime years after 2017. (2) Define a and b to be a5666668532329037424074138019351214527900, and b 30650433630342066289005004723923980642610. Let d- ged(a, b). Count how many solutions (x, y) there are to the linear Diophantine equation ax + by d satisfying the condition 0
Explanation / Answer
import itertools
import math
# function to check if the number is prime or not
def is_prime(n):
if n % 2 == 0 and n > 2:
return False
for i in range(3, int(math.sqrt(n)) + 1, 2):
if n % i == 0:
return False
return True
count = 0
# this runs the for loop infinitly until the count condition is complete
for x in itertools.count(2016,1):
if count == 5:
break
else:
a=x+1
# a%2 return the remainder after dividing
if is_prime(x)==True and (a)%2==0 and (a)%3==0:
print(x, " is a triple prime number")
count = count + 1
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.