Merge branch 'feature-bash-scripts'
This commit is contained in:
11
main.sh
Executable file
11
main.sh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Введите 1е число:"
|
||||||
|
read num1
|
||||||
|
|
||||||
|
echo "Введите 2е число:"
|
||||||
|
read num2
|
||||||
|
|
||||||
|
echo "Результаты:"
|
||||||
|
./GCD.sh $num1 $num2
|
||||||
|
./script_LCM.sh $num1 $num2
|
||||||
17
script_LCM.sh
Executable file
17
script_LCM.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
a=$1
|
||||||
|
b=$2
|
||||||
|
|
||||||
|
temp_a=$a
|
||||||
|
temp_b=$b
|
||||||
|
|
||||||
|
while [ $temp_b -ne 0 ]; do
|
||||||
|
temp=$temp_b
|
||||||
|
temp_b=$((temp_a % temp_b))
|
||||||
|
temp_a=$temp
|
||||||
|
done
|
||||||
|
|
||||||
|
gcd=$temp_a
|
||||||
|
lcm=$(( (a * b) / gcd ))
|
||||||
|
|
||||||
|
echo $lcm
|
||||||
Reference in New Issue
Block a user