Skip to content

Instantly share code, notes, and snippets.

@vinloo
Last active April 6, 2019 11:22
Show Gist options
  • Select an option

  • Save vinloo/c875bdb32d5919c3099a7abb65c1f1e9 to your computer and use it in GitHub Desktop.

Select an option

Save vinloo/c875bdb32d5919c3099a7abb65c1f1e9 to your computer and use it in GitHub Desktop.
Greates Common Divisor as Linear Combination finder with steps for TI Calculators
ClrHome
ClrAllLists
Disp "ax + by = c"
Input "a = ",A
Input "b = ",B
Input "c = ",C
If gcd(A,B)≠C
Then
Disp "","Error: c ≠ gcd(a,b)"
Stop
End
{A,B}→L₁
{1,0}→L₂
{0,1}→L₃
1→I
While L₁(dim(L₁))
I+1→I
int(L₁(I-1)/L₁(I))→Q
If L₁(I-1)-Ans*L₁(I)=0
Then
Goto A
End
L₁(I-1)-Ans*L₁(I)→L₁(I+1)
L₂(I-1)-Q*L₂(I)→L₂(I+1)
L₃(I-1)-Q*L₃(I)→L₃(I+1)
End
Lbl A
Disp "","x = ",L₂(dim(L₂))
Disp "y = ",L₃(dim(L₃))
L₃→L₄
L₂→L₃
0→L₂(dim(L₁))
For(I,2,dim(L₁))
L₁(I)→L₂(I-1)
End
For(I,2,dim(L₄))
L₃(I)→L₅(I-1)
L₄(I)→L₆(I-1)
End
Disp "","Press 'stat' - 'Edit...'","to see the steps table."
Stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment