Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $1 -le 0 ];
- then
- echo "Invalid input. Enter a positive number."
- exit 1
- fi
- for((i=2; i<$1/2; i++)){
- if [ `expr $1 % $i` -eq 0 ];
- then
- echo "$1 is not prime."
- exit 1
- fi
- }
- echo "$1 is prime."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement