Question
C++, Java, or Python (Please help if you can) 1. Write a program that searches for near misses of the form (x, y, z, n,
C++, Java, or Python (Please help if you can)
1. Write a program that searches for near misses of the form (x, y, z, n, k) in the formula x^n + y^n = z^n , where x, y, z, n, k are positive integers, where 2< n <12, where 10 <= x <= k, and where 10 <= y <= k. Get n and k values from the user. K should be greater than 10. Your program should then look for near misses of the form x^n + y^n < > z^n . A near miss is a small difference between (x^n + y^n) and z^n for some integers x, y, and z. Your program should systematically search for x, y, and z combinations that are almost right. NOTE WELL: Fermats last theorem tells us that there should NOT be any x^n+ y^n = z^n combinations that are EXACTLY right for any n > 2. Also notice that although x and y are constrained above, z is NOT constrained directly. For each possible x,y combination, I suggest that you calculate (x^n+ y^n ), and then look for whole numbers z and z + 1 that bracket (x^n+ y^n), so that z^n < (x^n+ y^n) < (z+1)^n. Find out which one (either z^n or (z+1)n) is closer to (x^n+ y^n), and determine the miss as the smallest of these two values: [(x^n+ y^n) - z^n] or [(z+1)n- (x^n+ y^n)]. Then divide that miss by (x^n+ y^n ) to obtain the RELATIVE size of the miss. Do this for all the possible combinations available, always keeping track of the smallest relative miss so far. Every time you find a new smallest relative miss, type out to the screen the current x, y, z, the actual miss (an integer), and the relative miss (a percentage or fraction). Make sure the interactive user can tell what the numbers mean as they are printed out; that is, label them well. When you have exhausted all the x, y, z triples possible, end the program. The screen should show the smallest possible miss as the last thing printed on the screen.
Step 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