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

24 lines
418 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
exit 1
fi
if ! [[ "$1" =~ ^[0-9]+$ ]] || ! [[ "$2" =~ ^[0-9]+$ ]]; then
echo "Ошибка: Аргументы должны быть целыми положительными числами"
exit 1
fi
num1=$1
num2=$2
source ./nod.sh
source ./noc.sh
gcd=$(gcd $num1 $num2)
echo "НОД($num1, $num2) = $gcd"
lcm=$(lcm $num1 $num2)
echo "НОК($num1, $num2) = $lcm"