Well, problem number 9 was an interesting return to the world of Pythagoras. If you haven't looked at the riddle, here it is:

Find the only Pythagorean triplet, {

`a`,

`b`,

`c`}, for which

`a`+

`b`+

`c`= 1000.

OK. The first thing we know is that

`a`

^{2}+

`b`

^{2}=

`c`

^{2}is Pythagorean Theorem.

Now to find Pythagorean Triplets with positive whole numbers(natural numbers) we could try iterating through the infinite set of number until we found the right set or we could use this formula:

`a`= 2

`mn`

`b`=

`m`

^{2}-

`n`

^{2}

`c`=

`m`

^{2}+

`n`

^{2}

where m > n > 0

So now we have:

1000 = a + b + c

1000 = (2

1000 = 2

500 =

500 =

(500/

(500/

You now have what you need to write a program to find your triplet. I'll give you my inplementation later.

1000 = (2

`mn`) + (`m`^{2}-`n`^{2}) + (`m`^{2}+`n`^{2})1000 = 2

`mn`+ 2`m`^{2}+ 0500 =

`mn`+`m`^{2}500 =

`m`(`n`+`m`)(500/

`m`) =`n`+`m`(500/

`m`) -`m`=`n`

You now have what you need to write a program to find your triplet. I'll give you my inplementation later.

## 1 comment:

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru Dot Net Training in Chennai. Nowadays Dot Net has tons of job opportunities on various vertical industry.

or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

Post a Comment