aboutsummaryrefslogtreecommitdiff
path: root/test.sh
blob: e949ce274c25ebc9aa4364c3a304ec8e7ee35abb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Bash

gcd() {
    if (( $2 > 0 ))
    then
        echo $( gcd $2 $(( $1 % $2 )) )
    else
        echo $1
    fi
}

echo test

declare -i N=1000
declare -a A
for ((i=0;i<N;i++))
do
    A[i]=$i
done

declare -i ans=0
for i in "${A[@]}"
do
    for j in "${A[@]}"
    do
        ans=$(( $(gcd $i $j) + ans ))
    done
done
echo $ans