#!/bin/bash
sum=0
for ((i=1;i<=10;i+=2))
do
((sum+=i))
done
echo sum=$sum
#!/bin/bash
sum=0
for ((i=1;i<=10;i+=2))
do
let sum+=i
done
echo sum=$sum
#!/bin/bash
sum=0
for ((i=1;i<=10;i++))
do
if [ $((i%2)) -eq 1 ]
then
((sum+=i))
else
continue
fi
done
echo sum=$sum
#!/bin/bash
sum=0
for ((i=1;j<=10;i++))
do
if [ `expr $i % 2` -eq 1 ]
then
let sum+=$i
else
continue
fi
done
echo sum=$sum
#!/bin/bash
sum=0
for ((i=1;i<=10;i++))
do
if [ $((i%2)) -eq 0 ]
then
((sum+=i))
else
continue
fi
done
echo sum=$sum
#!/bin/bash
sum=0
for ((i=1;i<=10;i++))
do
if [ `expr $i % 2` -eq 0 ]
then
let sum+=i
else
continue
fi
done
echo sum=$sum
网友评论