Computer Science, asked by siddhibhavyaa6531, 11 months ago

Write a shell script to find n numbers and will display first five prime numbers

Answers

Answered by choudhary21
1

Explanation:

✍✍✍Input:

N = 43

Output: Prime Input: N = 35

Output: Not Prime.

Prime Numbers: First few prime numbers are : 2 3 5 7 11 13 17 19 23 Approach:

Answered by Anonymous
1

Answer:

Explanation:

In the post " " we saw how we can use the command factor to find whether a number is prime of not. We can extend the same script further to generate all the prime numbers in a given range of numbers.  

To generate a range of numbers we can use the command "seq" . The usage of seq is shown in the post " ".

We can use seq in a for loop to iterate over one number at time.  

for mun in `seq 4 10`

do

echo $mun

done  

 

Save the script as seq_for.sh, give it execute permissions and run the script.  

Similar questions