#!/bin/bash
n=0
while [ $n -lt 1 ]
do
read "please input a number ,it must greater than "1":" n
done
sum=0
for i in `seq 1 $n`
do
sum=$[$i+$sum]
done
echo $sum
本文出自 “IT屌丝” 博客,请务必保留此出处http://68686789.blog.51cto.com/10438688/1690636
输入数字,计算从1到输入数字的和,要求输入小于1,重输直到输入正确的数字为止
原文地址:http://68686789.blog.51cto.com/10438688/1690636