Skip to content

Instantly share code, notes, and snippets.

@not-inept
Created September 20, 2018 03:19
Show Gist options
  • Save not-inept/ba6de198f97951aaac45dbfbe5817ae0 to your computer and use it in GitHub Desktop.
Save not-inept/ba6de198f97951aaac45dbfbe5817ae0 to your computer and use it in GitHub Desktop.
1: 1776 = 1 * 1492 + 284
2: 1492 = 5 * 284 + 72
3: 284 = 3 * 72 + 68
4: 72 = 1 * 68 + 4
5: 68 = 17 * 4 + 0
-----------------------------------------------
6: 4 = 72 - 1(68) # start from line 4, solved for the gcd
7: 4 = 72 - 68
8: 4 = 72 - (284-3(72)) # substitute from line 3, solved for 68
9: 4 = (1492 - 5(284)) - (284-3((1492 - 5(284)))) # substitute from line 2, solved for 72
10: 4 = (1492 - 5((1776 - 1492))) - ((1776 - 1492)-3((1492 - 5((1776 - 1492))))) # substitute from line 1, solved for 284
11: a = 1776 # this just makes it easier to follow, we'll replace
12: b = 1492 # our inputs with a and b:
13: 4 = (b - 5((a - b))) - ((a - b)-3((b - 5((a - b))))) # replaced our inputs with a and b
14: 4 = b - 5a + 5b -a + b +3b -15a +15b) # distribute/multiply constants
15: 4 = (-5-1-15)a + (1+5+1+3+15)b # combine like terms
16: 4 = -21a + 25b # waahlaa!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment