Files
github/main.sh
2026-02-28 11:22:14 +03:00

26 lines
583 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
if [ $# -ne 2 ]; then
echo "Использование: $0 <число1> <число2>"
echo "Пример: $0 12 18"
exit 1
fi
if ! [[ "$1" =~ ^[0-9]+$ ]] || ! [[ "$2" =~ ^[0-9]+$ ]]; then
echo "Ошибка: Аргументы должны быть целыми положительными числами"
exit 1
fi
num1=$1
num2=$2
echo "Вычисление для чисел: $num1 и $num2"
source ./nod.sh
source ./nok.sh
gcd=$(gcd $num1 $num2)
echo "НОД($num1, $num2) = $gcd"
lcm=$(lcm $num1 $num2)
echo "НОК($num1, $num2) = $lcm"