From 675affe7295f9c9716b0d69ed3456fbe13e38621 Mon Sep 17 00:00:00 2001 From: gyg72 Date: Fri, 27 Feb 2026 21:16:51 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=9D=D0=9E=D0=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script_LCM.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 script_LCM.sh diff --git a/script_LCM.sh b/script_LCM.sh new file mode 100755 index 0000000..b86b3de --- /dev/null +++ b/script_LCM.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +if [ $# -ne 2 ]; then + echo "Использование: $0 <число1> <число2>" + exit 1 +fi + +a=$1 +b=$2 + +gcd() { + local x=$1 + local y=$2 + while [ $y -ne 0 ]; do + local t=$((x % y)) + x=$y + y=$t + done + echo $x +} + +gcd_val=$(gcd $a $b) +lcm=$(( (a * b) / gcd_val )) + +echo $lcm