Project Euler > Problem 192 > Best Approximations (Java Solution)


Let x be a real number.
A best approximation to x for the denominator bound d is a rational number r/s in reduced form, with s [≤] d, such that any rational number which is closer to x than r/s has a denominator larger than d:

|p/q-x| [<] |r/s-x| [⇒] q [>] d

For example, the best approximation to [√]13 for the denominator bound 20 is 18/5 and the best approximation to [√]13 for the denominator bound 30 is 101/28.

Find the sum of all denominators of the best approximations to [√]n for the denominator bound 1012, where n is not a perfect square and 1 [<] n [≤] 100000.



The solution may include methods that will be found here: .

public interface EulerSolution{

public String run();

We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.

No comments :

Post a Comment

Follow Me

If you like our content, feel free to follow me to stay updated.


Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?


Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact