add scripts v1

This commit is contained in:
dashamaxet-s
2026-02-22 00:17:13 +03:00
commit 38f05dee34
2 changed files with 32 additions and 0 deletions

12
main.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/bin/bash
echo "calculashion gcd and lcm"
echo "pls write first agr"
read num1
echo "pls write second agr"
read num2
gcd=$(./script_GCD.sh $num1 $num2)
echo "GCD for $num1 and $num2 is $gcd"

20
script_GCD.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
if [ $# -ne 2 ]; then
echo "error, pls whrite 2 arguments"
exit 1
fi
a=$1
b=$2
while [ $b -ne 0 ]; do
ostatok=$((a % b))
a=$b
b=$ostatok
done
echo $a