Skip to content

Commit 6fd02b8

Browse files
committed
更新
1 parent 1e2e067 commit 6fd02b8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cut_and_dried/gcd_lcm.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ function GCD() {
2424

2525
function LCM() {
2626
echo $((($1*$2)/$(GCD $1 $2)))
27+
}
28+
29+
# tmp無しバージョン(余計長くなった)
30+
function GCD() {
31+
local -r r='n?n=n^m,m=n^m,n=(n^m)%m,r:m'
32+
echo $((m=$1>$2?$1:$2,n=$1^$2^m,r))
2733
}

0 commit comments

Comments
 (0)