Académique Documents
Professionnel Documents
Culture Documents
}
return b;
}
calcul de ppcm: public static int ppcm(int a,int b){
int ppcm=(a*b)/pgcd(a,b);
return ppcm;
}
décomposition et calcul de nombre premier:
public static boolean premiere(int n){
if(n<=1)
return false;
for(int i=2;i<n;i++){
if(n%i==0)
return false;
}
return true;
package tp01;
la recherche dichotomique public static int rechdicho( int tab[],int n,int x){
boolean trouve=false;
int g=0;
int h=n-1;
int m;
do{
m=(g+h)/2;
if(tab[m]==x){
trouve=true;
}
else if(tab[m]<x){
g=m+1;
}
else{
h=m-1;
}
}while(!trouve);
return(m);
}
}