・ ・ ・ ・ ・ ・ ・ ・ ・ ・  前へ←→次へトップへ戻る
その2. 2つの数約数をすべて求めてみます。

サンプルと結果

ソース(スクリプト側)
<script>
function common_divisor_2(cd1,cd2){

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){ document.write(cd); 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){document.write(' / ',cd);} document.write('
'); } } } </script>

ソース(呼び出し側)
common_divisor_2(24,60)

・・・・・・・・・・>もどる。