| Lecture 3 - slide 22 : 39 Program 1 |
import oopcourse.util.Console;
class Gcd2{
static int gcd(int input1, int input2){
int stor, lille, rest;
stor = input1; lille = input2;
for(stor=input1, lille = input2;
lille > 0;
rest = stor % lille, stor = lille, lille = rest);
return stor;
}
public static void main(String args[]){
int i, j;
i = Console.readInt("Indlæst det største af to positive tal");
j = Console.readInt("Indlæst det mindst af to positive tal");
System.out.println("GCD = " + gcd(i,j));
}
}
|