编写一个Shell,求100以内偶数的和。
#!/bin/bash echo "Compute the sum of the even number which between 1 and 100..." SUM=0 for i in $(seq 100) do if [ $((i%2)) == 0 ]; then ((SUM+=i)) fi done echo "The result is $SUM"
参照原文:https://blog.csdn.net/muyanmoyang/article/details/48136945
不忘初心,方得始终 --
The very beginning mind itself is the most accomplished mind of true enlightenment。

浙公网安备 33010602011771号