qfedu-linux-advanced-level/day1/homework/h2.sh

11 lines
205 B
Bash
Raw Permalink Normal View History

2023-08-14 20:13:50 +08:00
#!/bin/bash
# 编写一个Shell脚本计算1到100之间所有3倍数的整数和svi
declare -i svi=0
for (( i=1;i<=100;i++ )); do
if (( i%3==0 )); then
svi+=i
fi
done
echo "svi="$svi