[Community Puzzle] Primitive Pythagorean Triples

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @NicolasAlmerge,validated by @Lysk,@nicola and @CodinBoss1234.
If you have any issues, feel free to ping them.

It is too much a Math problem with too little relationship to programming.
No way for me to digest all these Math theories from tons of unfamiliar Math writtings.
I’m just not in this field. Give up.

Continuing the discussion from [Community Puzzle] Primitive Pythagorean Triples:

An interesting little challenge.
You have to translate simple mathematical conditions using programming skills.

Hints : Pythagorean triple - Wikipedia

I don’t have the same results.
So, I took your python solution, and each time you increase the number of triplets found, I display them:
print(str(n * n) + “+” + str(m * m) + “=” + str(m * m + n * n))

And so, here is the list of the 24 triplets found for the 3rd validator:
1+4=5
4+9=13
1+16=17
9+16=25
4+25=29
16+25=41
1+36=37
25+36=61
4+49=53
16+49=65
36+49=85
1+64=65
9+64=73
25+64=89
49+64=113
4+81=85
16+81=97
64+81=145
1+100=101
9+100=109
49+100=149
4+121=125
16+121=137
1+144=145

For 9+16=25, I agree: 25 is the square of 5.
But what about the others? Their c² is not a square.

Even Pythagorean triple - Wikipedia indicates: “there are 16 primitive Pythagorean triples of numbers up to 100”.

n and m are values for euclids formula (the wikipedia page you linked has more info on this), not a and b in the pythagoras formula.

You can convert n and m into a, b and c:

  • a = m * m - n * n
  • b = 2 * m * n
  • c = m * m + n * n.