84 407
Assignments Done
99%
Successfully Done
In March 2020

# Answer to Question #2177 in Python for Callie Camper

Question #2177
& Even numbers and primes. &lt;br&gt;(a) Write a is_prime(n) function. &lt;br&gt; It should accept a positive integer n&gt;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 &lt; d &lt; sqrt(n), d divides n. I&#039;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). &lt;br&gt;&lt;br&gt; (b) Write a prime_sum(n) function.&lt;br&gt; It should accept an even number n&gt;1 as input, and via a loop search for primes p &amp; 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. &lt;br&gt;&lt;br&gt; (c) Main. &lt;br&gt;i) Ask the user for an even number n. Continually ask them until they do give you a positive even number. &lt;br&gt; ii) Search for the summands p &amp; q, and either print them out (if they exist) or say they don&#039;t. &lt;br&gt; iii) Ask the user if they wish to try with another even, and let them continue until they quit.
1
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.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!