Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created May 24, 2017 11:17
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 peter279k/cb113d0538e622b17a5d948bae9ffd4c to your computer and use it in GitHub Desktop.
Save peter279k/cb113d0538e622b17a5d948bae9ffd4c to your computer and use it in GitHub Desktop.
TQC+ JAVA
import java.util.*;
public class JPA03 {
public static void main (String argv[]) {
int num1, num2;
System.out.println("Input:");
Scanner input = new Scanner(System.in);
num1 = input.nextInt();
while(true) {
if(num1 == 999) {
break;
}
num2 = input.nextInt();
System.out.println(gcd(num1, num2));
System.out.println("Input:");
num1 = input.nextInt();
}
}
static int gcd(int m, int n) {
if(n < m) {
int temp = m;
m = n;
n = temp;
}
while(m % n != 0) {
int temp = m % n;
m = n;
n = temp;
}
return n;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment