pythagorean

Efficiently calculating all pythagorean triples knowing the hypoteneuse

Given a hypoteneuse (c in the typical equation a*a + b*b = c*c), what is an efficient way to calculate all possible integer values of a and b, such that a < b? Note: I've seen c be greater than 1e12, thus c*c is greater than long.MaxValue, from what I can tell, c*c does fit into a decimal, though. ...

Find Pythagorean triplet for which a + b + c = 1000

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. Source: http://projecteuler.net/index.php?section=problems&amp;id=9 I tried but didn't know where my code...

iPhone SDK math - pythagorean theorem problem!

Just as a practice, I am working on an app that solves the famous middle school pythagorean theorem, a squared + b squared = c squared. Unfortunately, the out-coming answer has, in my eyes, nothing to do with the actual answer. Here is the code used during the "solve" action. - (IBAction)solve { int legoneint; int legtwoint; int hy...

Optimum algorithm to calculate pythagorean triplet

I have a question for everyone. I have this problem statement where in given, x^2 + y^2 = c is the equation, you have to optimally find the tuples (x,y) such that the equation holds true. Given a variable c, whose value is known, you have to find the values (x,y). So suppose if you have c=0, then x=0 and y=0. Suppose you have c=2, then...