add scripts v1
This commit is contained in:
12
main.sh
Executable file
12
main.sh
Executable 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
20
script_GCD.sh
Executable 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user