高斯算法如下:
#/bin/bash
source ./afunction.sh
if [ -z $1 ]; then
echo "please input number !Now will be exit!"
exit 1
fi
x=$1
IsNumber $x
r=$?
if [ $r -gt 0 ]; then
echo "please input number !Now will be exit!!"
exit 1
fi
is2 $x
y=$?
if [ $y -eq 0 ];then
m=0
k=0
else
m=1
k=x
fi
let n=(x-m)/2
let sum=(x-m+1)*n+k
echo $x
echo $n
echo "Result : " $sum