Home > Miscellaneous > Problem 009

Problem 009

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^(2) + b^(2) = c^(2)

For example, 3^(2) + 4^(2) = 9 + 16 = 25 = 5^(2).

There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.

Solution:
Function Prob009() As Long
For a As Integer = 0 To 1000
For b As Integer = 0 To 1000
For c As Integer = 0 To 1000
If (a + b + c) = 1000 AndAlso a < b AndAlso b < c AndAlso System.Math.Pow(a, 2) + System.Math.Pow(b, 2) = System.Math.Pow(c, 2) Then Return a * b * c
Next
Next
Next
End Function

Summary:
Pretty easy...

Tags:
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.