|
|
| Welcome to the Monastery | |
| PerlMonks |
Re^2: Prime Number Finderby Anonymous Monk |
| on Jan 20, 2013 at 19:36 UTC ( #1014322=note: print w/ replies, xml ) | Need Help?? |
|
this is the actual code that works on windows and generates prime numbers upto the number you wish, check below code: #!usr/bin/perl -w use strict; use warnings; my $o = 2; print "enter upto what no.you wish generate the primes: "; my $e = <STDIN>; my ($i,$j,$p); my @prime_=(); print "prime numbers are:\n"; for($i=$o; $i<=$e; $i++){ $p=0; for($j=1; $j<=$i; $j++){ if($i % $j== 0){ $prime_$p = "$j"; $p++; } if ($prime_1 == $i) { print "$i\t"; } } } print"\n";
In Section
Snippets Section
|
|
||||||||||||||||||||||