392,502 views
7 votes
7 votes
NO LINKS

write a shell script to find the sum of all integers between 100 and 200 which are divisible by 9​

User Alex Ghiculescu
by
3.3k points

1 Answer

27 votes
27 votes

Answer:

#!/usr/bin/env bash

for num in {100..200}

do

if [ $((num % 9)) -eq 0 ]

then

((sum += num))

fi

done

echo $sum

Step-by-step explanation:

The output will be 1683.

User Bruno Rijsman
by
3.0k points