Question
Write a Shell Script program to find Greatest Common Divisor (GCD) for any two numbers. Ensure that your script carries out basic error checking
Answer :
Word Count : 315
_______ __________ ________ ________ ___ ______.
_______ _______ __________ __________ _________ ________.
_______ ______ __________ ______ _____.
_____ ________ ____ __________ ____.
______ ____ ______ ___ ________ _______ __________ _________ ___.
______ _____ __________ _____ __________ _________ _________ _________ _____.
________ ______ ________ ______ ________ _____ ___ ____ ___.
____ __________ ______ ___ ______ __________ _____ _________ ___ ___ ________.
_________ ___ _______ _______ ____ ________ __________ __________ ___ ____ ________.
_______ ______ __________ _______ _______ __________ _______ ______ ______ _____ _____.
___ _______ ___ _______ __________ _______ ____ ____ _________ ________.
__________ _______ ____ ________ _________ ___ ______.
____ __________ _______ ___ _____ _________ ________ _______ __________ __________ __________.
_____ __________ ________ ____ _____ _________ _____ _______.
___ _______ ____ ___ ________ _____ ______ __________ ______.
________ ___ ___ ____ _______ _____ ______ ______ ___ _______ ______ _________.
_________ ________ ______ ________ ______ ______ ________.
______ ________ _____ _____ ______ _________ ______ ____ _____ _________ _________.
__________ ___ _____ _________ ________ ___ _________ _____ ______ __________ ______.
________ __________ __________ __________ __________ ______ ____ ____ __________ _______ ___.
____ __________ _______ __________ ____ ___ _______ _________ _________ ___ ___.
___ _______ _______ _________ ______ ___.
________ ___ __________ ______ __________ __________ _____ _________ __________ _________.
_______ _________ ______ ___ ______ __________ ______ ______ _______ _________.
_______.
Skip in 10
To write a Shell Script program to find the Greatest Common Divisor (GCD) for any two numbers, we can use the Euclidean algorithm. The Euclidean algorithm is a simple and efficient algorithm for finding the GCD of two numbers.
Here is a sample script to find the GCD of two numbers using the Euclidean algorithm:
#!/bin/bash
echo "Enter the first number:"
read num1
echo "Enter the second number:"
read num2
# Basic error checking
if [ "$num1" -le 0 ] || [ "$num2" -le 0 ]
then
echo "Error: Please enter
_______ _______ __________ __________ _________ ________.
_______ ______ __________ ______ _____.
_____ ________ ____ __________ ____.
______ ____ ______ ___ ________ _______ __________ _________ ___.
______ _____ __________ _____ __________ _________ _________ _________ _____.
________ ______ ________ ______ ________ _____ ___ ____ ___.
____ __________ ______ ___ ______ __________ _____ _________ ___ ___ ________.
_________ ___ _______ _______ ____ ________ __________ __________ ___ ____ ________.
_______ ______ __________ _______ _______ __________ _______ ______ ______ _____ _____.
___ _______ ___ _______ __________ _______ ____ ____ _________ ________.
__________ _______ ____ ________ _________ ___ ______.
____ __________ _______ ___ _____ _________ ________ _______ __________ __________ __________.
_____ __________ ________ ____ _____ _________ _____ _______.
___ _______ ____ ___ ________ _____ ______ __________ ______.
________ ___ ___ ____ _______ _____ ______ ______ ___ _______ ______ _________.
_________ ________ ______ ________ ______ ______ ________.
______ ________ _____ _____ ______ _________ ______ ____ _____ _________ _________.
__________ ___ _____ _________ ________ ___ _________ _____ ______ __________ ______.
________ __________ __________ __________ __________ ______ ____ ____ __________ _______ ___.
____ __________ _______ __________ ____ ___ _______ _________ _________ ___ ___.
___ _______ _______ _________ ______ ___.
________ ___ __________ ______ __________ __________ _____ _________ __________ _________.
_______ _________ ______ ___ ______ __________ ______ ______ _______ _________.
_______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
Continue Reading — It's Free
Sign in with Google to unlock more of this answer.
✓ Free access
✓ Unlock up to 60% of the answer
✓ No payment required
✓ Unlock up to 60% of the answer
✓ No payment required
Quick Google sign-in. No separate registration form.