<script>
function common_divisor_24(cd1,cd2){
var text='公約数は、\n';
if(cd1 > cd2) {cd_L = cd1; cd_S = cd2;}
if(cd1 < cd2) {cd_L = cd2; cd_S = cd1;}
document.write(cd_L,' ');
document.write(cd_S,' ');
document.write('******************** ');
for (i=0; i < cd_S; i++){
cd = cd_S - i;
cd_with_rest_L = cd_L/(cd);
cd_check_L = cd_with_rest_L-Math.floor(cd_with_rest_L);
if(cd_check_L == 0){
cd_with_rest_S = cd_S/(cd);
cd_check_S = cd_with_rest_S-Math.floor(cd_with_rest_S);
if(cd_check_S == 0){text=text+cd+'\n';}
}
}
alert(text);
}
</script>
|