Files
ErmakovMorozov/script_NOK.sh

25 lines
335 B
Bash
Executable File
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"
exit 1
fi
a=$1
b=$2
# Находим НОД
nod_a=$a
nod_b=$b
while [ "$nod_b" -ne 0 ]; do
temp=$nod_b
nod_b=$((nod_a % nod_b))
nod_a=$temp
done
# НОК = (a * b) / НОД
nok=$(( (a * b) / nod_a ))
echo "$nok"