qfedu-linux-advanced-level/day1/d29.sh

18 lines
236 B
Bash
Raw Permalink Normal View History

2023-08-14 17:48:45 +08:00
#!/bin/bash
function isZs()
{
declare -i n
n=$1
for(( i=2; i<n; i++ )); do
if (( n%i == 0 )); then
return 1
fi
done
return 0
}
isZs $1
if [[ $? -eq 0 ]] ; then
echo "$1 是素数"
fi