first exe

This commit is contained in:
21_SkvortsovKV
2026-02-28 15:14:33 +03:00
parent e841a6a178
commit 5ee6e57d86
3 changed files with 30 additions and 0 deletions

9
main.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
echo "Введите первое число:"
read num1
echo "Введите второе число:"
read num2
gcd_res=$(./script_GCD.sh $num1 $num2)
lcm_res=$(./script_LCM.sh $num1 $num2)
echo "НОД($num1, $num2) = $gcd_res"
echo "НОК($num1, $num2) = $lcm_res"

8
script_GCD.sh Executable file
View File

@@ -0,0 +1,8 @@
a=$1
b=$2
while [ $b -ne 0 ]; do
remainder=$((a % b))
a=$b
b=$remainder
done
echo $a

13
script_LCM.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
a=$1
b=$2
x=$a
y=$b
while [ $y -ne 0 ]; do
rem=$((x % y))
x=$y
y=$rem
done
g=$x
l=$(( (a * b) / g ))
echo $l