1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
public class PGCDRec {
/** Creates a new instance of PGCDRec */
static int PGCDRec( int A , int B ) {
if (A == B ){
return A ;
}else {
if ( A > B ){
return PGCDRec (A- B ,B);
}else {
return PGCDRec ( A , B-A );
}
}
}
public static void main (String [] args ){
int A, B ;
int pgcd ;
System.out.println ( "Saisir un entier A " );
A = Lire.entierInt () ;
System.out.println ( "Saisir un entier B " );
B = Lire.entierInt () ;
pgcd = PGCDRec (A, B);
System.out.println ("Le PGCD des 2 entiers saisi est " + pgcd );
}
} |
Partager