first exe
This commit is contained in:
9
main.sh
Executable file
9
main.sh
Executable 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
8
script_GCD.sh
Executable 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
13
script_LCM.sh
Executable 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
|
||||||
Reference in New Issue
Block a user