shell脚本素数运算
#!/bin/bash
st=date +%s
for i in {100010…100000}
do
cunt=0
j=1
while [ $j -le $ i ];
do
k=$(( $i % $j))
if [ $k -eq 0 ];then
let cunt+=1
fi
if [ $cunt -gt 2 ];then
break
fi
let j+=1
done
if [ $cunt -le 2 ];then
echo $ i
fi
done
et=date +%s
let et-=
s
t
e
c
h
o
"
耗
时
:
"
st echo "耗时:"
stecho"耗时:"et