Skip to content

Latest commit

 

History

History
28 lines (23 loc) · 292 Bytes

while语句.md

File metadata and controls

28 lines (23 loc) · 292 Bytes

while语句

while condition
do
    ...
done
#!/bin/bash

read -p "请输入m:" m
read -p "请输入n:" n

sum=0
while ((m <= n))
do
   ((sum+=m))
   ((m++))
done

echo "sum:$sum"

[root@iZ8vb6ughzbdqkfd58dowoZ bin]# shell_1.sh
请输入m:0
请输入n:9
sum:45