# Pythagorean triple

• ### Question

• I've got a task in my programming class. It's the following.

a Pythagorean triple is three integers, a <b <c where a ^ 2 + b ^ 2 = c ^ 2 for example, 3 ^ 2 + 4 ^ 2 = 5 ^ 2 There is exactly a Pythagorean triple where a + b + c = 1000. Find it.

Can i use varabels as uctual variabels like a < b <c and a + b + c = 1000 to find what a, b and c is or should i do something else?

Thursday, December 7, 2017 11:42 AM

### All replies

• Yes you can use variables like you would in a normal formula. Those variables can be changed by your program in order to find the solution. For example you might start by trying to determine what a is. For that you'll need to be adjusting the value of the variable a until you get something that will work. You'll be adjusting all your variables until you come up with the final answer. Only variables would work in this situation as you have to be able to read/write them at runtime.

Of course all your code will likely be wrapped in a set of functions/methods that you're using to do the actual calculations. For example you may have a high level function that does the actual calculation. You might then have another function that uses the earlier function and passes test values to it. This allows you to separate out the code based upon what it is doing.

Your programming class and instructor should be able to explain (or already have) this to you. Your programming book should have plenty of examples as well.

Michael Taylor http://www.michaeltaylorp3.net

Thursday, December 7, 2017 2:40 PM
• Hello Dacke2000,

Your description looks like homework on myside. The CoolDadTx has pointed the right direction for you. This is easy job as long as you try it. If you have any concerns, please do not hesitate to let us know. And you could mark the helpful reply as answer if you have got the solutions. Thanks a lot.

Best regards,

Neil Hu

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

Sunday, December 24, 2017 8:09 AM