分别计算100以内的奇数之和和偶数之和

for循环:

#!/bin/bash
#Description:sum odd , sum even
#Author:fansik
#Script:second script
declare -i oddSum=0,evenSum=0
for odd in `seq 1 2 100`; do
    oddSum=$[$oddSum+$odd]
done
for even in `seq 2 2 100`; do
    let evenSum=$evenSum+$even
done
echo -e "The oddSum is $oddSum.
The evenSum is $evenSum."
原文地址:https://www.cnblogs.com/fansik/p/5599907.html