It should accept a positive integer n>1 as input, and output True or False, depending on whether n is or is not a prime number. Do this with a loop that checks whether for any integer d, 1 < d < sqrt(n), d divides n.
I'd suggest a while loop -- think carefully about the conditional for the loop, and when you want to change
this conditional inside the loop. (Use a boolean for your condition).
(b) Write a prime_sum(n) function.
It should accept an even number n>1 as input, and via a loop search for primes p & q with p + q = n.
Hint: start with p = 3. If (p) and (n-p) are prime you are done. If not, set p+=2 and try again.
(c) Main.
i) Ask the user for an even number n. Continually ask them until they do give you a positive even number.
ii) Search for the summands p & q, and either print them out (if they exist) or say they don't.
iii) Ask the user if they wish to try with another even, and let them continue until they quit.
1
Expert's answer
2011-03-29T05:37:29-0400
Unfortunately, your question requires more work than to be done for free. You can submit it as an assignment to our control panel set the deadline and our programmers will assist you.
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment