1、写一个函数lucky_number(),输出是一个1-100的随机整数
#!/bin/bash
lucky_number(){
beg=1
end=100
echo "The lucky number is $(( RANDOM % ($end-$beg) + $beg))"
}
for (( a = 0; a < 10; a ++ ))
do
lucky_number
done
2、打印从1-1000的素数,每个一行
#! /bin/bash
for (( i = 0; i < 1000; i++ )); do
for (( j = 2; j <= i - 1 ; j++ )); do
if [[ $(( i % j )) == 0 ]]; then
break
fi
done
[ $j == $i ] && echo "$j"
done