Skip to content

Instantly share code, notes, and snippets.

@smrfeld
Last active June 26, 2022 19:24
Show Gist options
  • Save smrfeld/59054643ad9179c2eeed08bccf42ec59 to your computer and use it in GitHub Desktop.
Save smrfeld/59054643ad9179c2eeed08bccf42ec59 to your computer and use it in GitHub Desktop.
Simplified Pythagorean triple
// b = (N^2 - 2Na) / (2N - 2a)
int num = n * n - 2 * n * a;
int denom = 2 * n - 2 * a;
if (num % denom != 0)
{
continue;
}
int b = num / denom;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment