Due at 11:59 pm on Thursday Oct. 26,2017 Part I: Finish the quiz \"HW3 -1\" in t
ID: 3602787 • Letter: D
Question
Due at 11:59 pm on Thursday Oct. 26,2017 Part I: Finish the quiz "HW3 -1" in the "quizzes" of iCollege. Note: You could have two attempts. The highest attempt will be considered as the final grade of this part Part Il: Writing programs 1) Write a Bourne Shell script named as "prime.sh" to display first n prime numbers. The value of n is input by user. Sample output: $./prime.sh Enter the value of n: 3 First 3 prime numbers are: 23 5 $./prime.sh Enter the value of n: 6 First 3 prime numbers are: 2 35 7 11 13 . Attach the source code and sample output of your "prime.sh" in the answer sheet. Upload "prime.sh" into iCollege. . MacBook AirExplanation / Answer
status=1
num=3
echo "Enter the value of"
read n
echo "First $n prime numbers are:"
if [ $n -ge 1 ]
then
echo "2"
fi
for((i=2;i -le $n;))
do
for((j=2;j -le sqrt($num);j++))
do
if [ `expr $num % $j` -eq 0 ]
then
status=0
break
fi
done
if [ $status -ne 0 ]
then
echo $num
i=`expr $i + 1`
fi
done
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.