Question: We have learned that 2 is not rational. However,2 can be arbitrarily well approximated by rational numbers. The goal of this programming exercise is to

We have learned that 2 is not rational. However,2 can be arbitrarily well approximated by rational numbers. The goal of this programming exercise is to find the best approximation p/q 2 with 2 q 100, 000. Write a Python program that iterates through all these q values. For each q, use the reasonable constraint 1.4 < p/q < 1.5 to come up with a small set of integer candidates p for a good approximation. Your program should output the (p, q) for which p/q approximates 2 best. Your program must not contain hardcoded approximations to 2, other than the numbers 1.4 and 1.5, or use Math.sqrt() or equivalent.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!