Skip to content

Instantly share code, notes, and snippets.

@chunkybanana
Created December 11, 2021 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chunkybanana/d4a5fc0fc756d1d24cf8429a175ddb7c to your computer and use it in GitHub Desktop.
Save chunkybanana/d4a5fc0fc756d1d24cf8429a175ddb7c to your computer and use it in GitHub Desktop.
All pythagorean triples can be generated from two integers m and n with the following:
a = m^2 - n^2
b = 2mn
c = m^2 + n^2
If either m or n is divisible by 3, then b is divisible by three. Else, there are three possibilities for m and n (modulo 3):
(2, 1) => 2^2 - 1^2 = 3, divisible by 3
(2, 2) => 2^2 - 2^2 = 0, divisible by 3
(1, 1) => 1^2 - 1^2 = 0, divisible by 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment