Print Prime Number upto 500 coderinme

Print Prime Number

Print prime number from 1 to 500. We know about prime number a number which is divisible by itself is called prime.

#!/bin/bash

for j in {2..500}; do
ch=0
upper=$((j/2))
for k in `seq 2 $upper`; do
if ((j%k==0)); then
let ch++
fi
done
if [ $ch -eq 0 ]; then
echo -n $j" "
else
continue
fi
done
echo

For more programs in shell, visit our Shell Coder Archives
Print prime number

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without prior written permission of website admin, except in case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme

A web developer(Front end and Back end), and DBA at csdamu.com. Currently working as Salesforce Developer @ Tech Matrix IT Consulting Private Limited. Check me @about.me/s.saifi

Leave a reply:

Your email address will not be published.