How to print prime numbers between 1 to 50? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite













This question already has an answer here:



  • Simple bash script to print prime numbers from 1 to 1000 [closed]

    1 answer



for i in `seq 1 1 50`
do
for j in `seq 2 1 $i`
do
if [ `expr i % j` -eq 0 ]
then exit
elif [ $i -eq `expr j+1` ]
then echo "$i"
fi
done
done


I tried this. But it's not working










share|improve this question







New contributor




Vraj Kotwala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by steve, Jeff Schaller, Stéphane Chazelas shell-script
Users with the  shell-script badge can single-handedly close shell-script questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
16 mins ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    echo '2 3 5 7 11 13 17 19 23 29 31 37 41 43 47' would be the most efficient.
    – Stéphane Chazelas
    14 mins ago














up vote
1
down vote

favorite













This question already has an answer here:



  • Simple bash script to print prime numbers from 1 to 1000 [closed]

    1 answer



for i in `seq 1 1 50`
do
for j in `seq 2 1 $i`
do
if [ `expr i % j` -eq 0 ]
then exit
elif [ $i -eq `expr j+1` ]
then echo "$i"
fi
done
done


I tried this. But it's not working










share|improve this question







New contributor




Vraj Kotwala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











marked as duplicate by steve, Jeff Schaller, Stéphane Chazelas shell-script
Users with the  shell-script badge can single-handedly close shell-script questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
16 mins ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    echo '2 3 5 7 11 13 17 19 23 29 31 37 41 43 47' would be the most efficient.
    – Stéphane Chazelas
    14 mins ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite












This question already has an answer here:



  • Simple bash script to print prime numbers from 1 to 1000 [closed]

    1 answer



for i in `seq 1 1 50`
do
for j in `seq 2 1 $i`
do
if [ `expr i % j` -eq 0 ]
then exit
elif [ $i -eq `expr j+1` ]
then echo "$i"
fi
done
done


I tried this. But it's not working










share|improve this question







New contributor




Vraj Kotwala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












This question already has an answer here:



  • Simple bash script to print prime numbers from 1 to 1000 [closed]

    1 answer



for i in `seq 1 1 50`
do
for j in `seq 2 1 $i`
do
if [ `expr i % j` -eq 0 ]
then exit
elif [ $i -eq `expr j+1` ]
then echo "$i"
fi
done
done


I tried this. But it's not working





This question already has an answer here:



  • Simple bash script to print prime numbers from 1 to 1000 [closed]

    1 answer







shell-script linux-mint






share|improve this question







New contributor




Vraj Kotwala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Vraj Kotwala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Vraj Kotwala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 21 mins ago









Vraj Kotwala

62




62




New contributor




Vraj Kotwala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Vraj Kotwala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Vraj Kotwala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




marked as duplicate by steve, Jeff Schaller, Stéphane Chazelas shell-script
Users with the  shell-script badge can single-handedly close shell-script questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
16 mins ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by steve, Jeff Schaller, Stéphane Chazelas shell-script
Users with the  shell-script badge can single-handedly close shell-script questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
16 mins ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









  • 1




    echo '2 3 5 7 11 13 17 19 23 29 31 37 41 43 47' would be the most efficient.
    – Stéphane Chazelas
    14 mins ago












  • 1




    echo '2 3 5 7 11 13 17 19 23 29 31 37 41 43 47' would be the most efficient.
    – Stéphane Chazelas
    14 mins ago







1




1




echo '2 3 5 7 11 13 17 19 23 29 31 37 41 43 47' would be the most efficient.
– Stéphane Chazelas
14 mins ago




echo '2 3 5 7 11 13 17 19 23 29 31 37 41 43 47' would be the most efficient.
– Stéphane Chazelas
14 mins ago










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Duplicate of an existing answer, but essentially just use factor 1..50|awk 'NF==2print $2'






share|improve this answer



























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Duplicate of an existing answer, but essentially just use factor 1..50|awk 'NF==2print $2'






    share|improve this answer
























      up vote
      0
      down vote













      Duplicate of an existing answer, but essentially just use factor 1..50|awk 'NF==2print $2'






      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Duplicate of an existing answer, but essentially just use factor 1..50|awk 'NF==2print $2'






        share|improve this answer












        Duplicate of an existing answer, but essentially just use factor 1..50|awk 'NF==2print $2'







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 16 mins ago









        steve

        13.4k22251




        13.4k22251












            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)