#!/bin/bash
# Function to calculate GCD using the Euclidean algorithm
gcd() {
a=$1
b=$2
while [ $b -ne 0 ]; do
temp=$b
b=$((a % b))
a=$temp
done
echo "The GCD is: $a"
}
# Prompt the user for two numbers
echo "Please enter the first number:"
read num1
echo "Please enter the second number:"
read num2
# Check if the inputs are valid integers
if [[ $num1 =~ ^-?[0-9]+$ ]] && [[ $num2 =~ ^-?[0-9]+$ ]]; then
# Call the function to calculate GCD
gcd "$num1" "$num2"
else
echo "Invalid input. Please enter valid integers."
fi