aboutsummaryrefslogtreecommitdiff
path: root/test.sh
diff options
context:
space:
mode:
authorAnthony Wang2020-09-16 11:13:36 -0500
committerAnthony Wang2020-09-16 11:13:36 -0500
commit4080aefb0ee4d482e42dc2d949feca7c241bf6ec (patch)
tree2d851a4cbdb533ff0e1b092c5e5557276389010d /test.sh
parent0ee764d6429b375e848f656b02a744df17fa71a2 (diff)
Add test.sh
Diffstat (limited to 'test.sh')
-rwxr-xr-xtest.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/test.sh b/test.sh
new file mode 100755
index 0000000..e949ce2
--- /dev/null
+++ b/test.sh
@@ -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