diff --git a/main.sh b/main.sh new file mode 100755 index 0000000..ff3d781 --- /dev/null +++ b/main.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +echo "Введите 1е число:" +read num1 + +echo "Введите 2е число:" +read num2 + +echo "Результаты:" +./GCD.sh $num1 $num2 +./script_LCM.sh $num1 $num2 diff --git a/script_LCM.sh b/script_LCM.sh new file mode 100755 index 0000000..1f4982e --- /dev/null +++ b/script_LCM.sh @@ -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