Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

how to check prime number in shell script

#!/bin/bash
echo -e "Enter Number : c"
read n
for((i=2; i<=$n/2; i++))
do
  ans=$(( n%i ))
  if [ $ans -eq 0 ]
  then
    echo "$n is not a prime number."
    exit 0
  fi
done
echo "$n is a prime number."
Comment

PREVIOUS NEXT
Code Example
Shell :: install svelte 
Shell :: create alias ubuntu 
Shell :: add to path windows powershell 
Shell :: check full memory details 
Shell :: conda python versions 
Shell :: netstat centos ports 
Shell :: sudo apt install microsoft-edge-dev 
Shell :: install arial font to linux 
Shell :: bash dev/null 
Shell :: npm command not found 
Shell :: ngrok with netcat 
Shell :: kill screen ubuntu 
Shell :: push an existing github repository 
Shell :: bash windows open folder in exporer 
Shell :: bash get length of every nth row 
Shell :: remove/undo all modified files git 
Shell :: update flutter command 
Shell :: nmcli connection status 
Shell :: how to install apache server in ubuntu 
Shell :: how to delete prerouting rule in linux 
Shell :: run sudo command with password in one line 
Shell :: echo /etc/hosts permission denied 
Shell :: qcow2 to vdi 
Shell :: installing firefox on debian 
Shell :: Katie Leung 
Shell :: powershell disk space 
Shell :: install werkzeug 
Shell :: generate ssh in ubuntu 
Shell :: tensorflow python 3.9 
Shell :: ethers install 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =