Question
Download the file prime.py, which contains the function isprime that checks if a number is prime. We disscussed this function in class. Copy this function
Download the file prime.py, which contains the function isprime that checks if a number is prime. We disscussed this function in class. Copy this function into your file.
Here is the Goldbarch Conjecture:
Every even natural number greater that 3 is the sum of 2 primes.
1) write a function that takes an even number as input and either prints out a way that the number can be written as the sum of two primes (there may be more than one, just print one) or prints a message that the conjecture is false.
2) Modify your function to another one that returns True if the conjecture is true for n and False if n can't be written as the sum of two primes.
3) Use the function in part 2 to check if the conjecture is true for all even numbers from 6 to 100,000.
please use python 3 for the program
1 #!/usr/bin/env python3 # -*- coding: utf-8 -* - AF AF AF Created on Mon Feb 1 11:06:30 2021 fauthor: Lance 2 3 4 5 6 7 8 9 10 11 12 AF LF UT def isprime(x): if x % 2 == 0: return false d = 3 done = False 14 15 16 17 18 19 20 result = True bound = round(x**(1/2)) 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 while not done: print(d) if x % d == 0: result = False done = True print(d, x//d) else: d = d + 2 if d> bound: done = True return result 1 #!/usr/bin/env python3 # -*- coding: utf-8 -* - AF AF AF Created on Mon Feb 1 11:06:30 2021 fauthor: Lance 2 3 4 5 6 7 8 9 10 11 12 AF LF UT def isprime(x): if x % 2 == 0: return false d = 3 done = False 14 15 16 17 18 19 20 result = True bound = round(x**(1/2)) 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 while not done: print(d) if x % d == 0: result = False done = True print(d, x//d) else: d = d + 2 if d> bound: done = True return resultStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started