#!/bin/bash
p=0
j=1
N=997
while [ $j -le $N ]
do
i=1
n=`expr $i \* $j`
while [ $n -le $N ]
do
n=`expr $i \* $j`
if [ $n -eq $N ];then
p=`expr $p + 1`
if [ $p -gt 2 ]; then
echo "$N is a composite number"
exit 0
fi
break
elif [ $n -gt $N ];then
break
fi
i=`expr $i + 1`
done
j=`expr $j + 1`
done
echo "$N is prime number"
exit 0
阅读(1341) | 评论(0) | 转发(0) |