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

14 lines
206 B
Bash
Raw Permalink Normal View History

2023-08-14 17:48:45 +08:00
#!/bin/bash
declare -i n
read -p "请输入一个整数: " n
for (( i=2; i<n; i++ )); do
if (( n%i == 0)); then
echo "$n 不是素数"
exit 1
fi
done
echo "$n 是素数"
echo "$n"