Greatest common divisor: Difference between revisions
Content deleted Content added
add gw basic |
|||
Line 5,062: | Line 5,062: | ||
==={{header|dash or bash}}=== |
==={{header|dash or bash}}=== |
||
Procedural : |
|||
<lang bash>gcd() { until test 0 -eq "$2";do set -- "$2" "$(($1 % $2))";done;if [ 0 -gt "$1" ];then echo "$((- $1))";else echo "$1"; fi } |
|||
gcd -47376 87843 |
|||
# => 987</lang> |
|||
Recursive : |
Recursive : |
||
<lang bash> |
<lang bash> |
||
Line 5,068: | Line 5,075: | ||
gcd 100 75 |
gcd 100 75 |
||
# => 25</lang> |
# => 25</lang> |
||
==={{header|C Shell}}=== |
==={{header|C Shell}}=== |