Skip to content

Instantly share code, notes, and snippets.

@NyaGarcia
Created January 13, 2024 16:46
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 NyaGarcia/9843a24afec87ae4665c0ef9818b23c5 to your computer and use it in GitHub Desktop.
Save NyaGarcia/9843a24afec87ae4665c0ef9818b23c5 to your computer and use it in GitHub Desktop.
Recursive Euclidean algorithm to calculate Greatest Common Divisor
function calculateGreatestCommonDivisor(a: bigint, b: bigint) {
if(b === 0n) {
return a;
}
return calculateGreatestCommonDivisor(b, a % b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment