Trying to write a basic shell script of the below question using GITBASH. Every time l try to run the code l get a syntax error, need help om how to fix this. below is the code. Find the even multiples of any number chosen by the user in a given range – the user should specify the multiples of which number they want to print and a minimum and maximum value. The multiples printed should be within the [minimum, maximum] range. For example, if the user choses the number 7 and would like to print all even multiples in the [15, 60] range, the program should print all the even multiples that are bigger than or equal to 15 (minimum), but smaller than or equal to 60 (maximum). The program should keep a count of how many numbers were printed and should output that count, as well as the numbers. The output then, for the example given, should be 28, 42, 56, and the count should be 3. #.sh code echo "Enter the number to find multiples:" read num echo "Enter the minimum and maximum range of values to display: " read min max echo count=0 #initialize index to 0 for (( i=$min; i <= $max; i+=2 )) do echo result[$count]=$i # If the i value is divisible by the number given and i is even then i is stored in result array ((count++)) #Increment count value by 1 ((i++)) #increment i value by 1 echo "Multiples in given range[$min,$max] : ${result[@]}" #Display the Multiples in the given range echo "Count of multiples is $count" #Display the count of multiples in the given range done
Trying to write a basic shell script of the below question using GITBASH. Every time l try to run the code l get a syntax error, need help om how to fix this. below is the code.
Find the even multiples of any number chosen by the user in a given range – the user
should specify the multiples of which number they want to print and a minimum and maximum
value. The multiples printed should be within the [minimum, maximum] range. For example, if
the user choses the number 7 and would like to print all even multiples in the [15, 60] range, the
program should print all the even multiples that are bigger than or equal to 15 (minimum), but
smaller than or equal to 60 (maximum). The program should keep a count of how many numbers
were printed and should output that count, as well as the numbers. The output then, for the
example given, should be 28, 42, 56, and the count should be 3.
#.sh code
echo "Enter the number to find multiples:"
read num
echo "Enter the minimum and maximum range of values to display: "
read min max
echo
count=0 #initialize index to 0
for (( i=$min; i <= $max; i+=2 ))
do
echo result[$count]=$i # If the i value is divisible by the number given and i is even then i is stored in result array
((count++)) #Increment count value by 1
((i++)) #increment i value by 1
echo "Multiples in given range[$min,$max] : ${result[@]}" #Display the Multiples in the given range
echo "Count of multiples is $count" #Display the count of multiples in the given range
done
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)