Add test.sh
This commit is contained in:
parent
0ee764d642
commit
4080aefb0e
29
test.sh
Executable file
29
test.sh
Executable file
|
@ -0,0 +1,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
|
Loading…
Reference in a new issue