public void startCalc(){ outTA.setText(""); s0 = 1; s1 = 0; t0 = 0; t1 = 1; r0String = r0TF.getText(); r0 = new Long(r0String).longValue(); r1String = r1TF.getText(); r1 = new Long(r1String).longValue(); if (r0 < r1) { helper1 = r0; r0 = r1; r1 = helper1; } while (r2 != 0) { r2 = r0 % r1; q = (int)Math.floor((double)(r0/r1)); s2 = s0 - q * s1; t2 = t0 - q * t1; r0 = r1; r1 = r2; s0 = s1; s1 = s2; t0 = t1; t1 = t2; } gcd = r1; r0 = new Long(r0String).longValue(); r1 = new Long(r1String).longValue(); outTA.append("gcd("+r0+","+r1+") = "+gcd+"\n"); outTA.append("s = "+s0+"\n"); outTA.append("t = "+t0+"\n\n"); outTA.append("Check:\n"); outTA.append("gcd / s,t: "+(s0 * r0 + t0 * r1));}