Finding Primes With Bash On Linux TUT
Page 1 of 1
Finding Primes With Bash On Linux TUT
- Code:
#! /bin/bash
low=1
count=0
while [ $low -eq 1 ]
do
echo "Enter the lower limit greater than 1"
read low
done
echo "Enter the upper limit"
read upper
for mun in `seq $low $upper`
do
ret=$(factor $mun | grep $mun | cut -d ":" -f 2 | cut -d " " -f 2)
if [ "$ret" -eq "$mun" ]
then
echo "$mun is a prime number"
((count++))
fi
done
echo -e "\n There are $count number of prime numbers"
Similar topics
» Linux Bash Asci Art
» Bash Psychic Game For Linux Bash
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» Finding the biggest files on linux and creating a function for biggest
» Linux Bash Who Am I Game Example
» Bash Psychic Game For Linux Bash
» Linux BASH Script Running Commands and Functions From Bash Script and saving to varables
» Finding the biggest files on linux and creating a function for biggest
» Linux Bash Who Am I Game Example
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|