Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Prime Number Finder

by Anonymous Monk
on Mar 31, 2016 at 17:01 UTC ( #1159212=note: print w/replies, xml ) Need Help??


in reply to Prime Number Finder

#!/usr/bin/perl # primenum.pl use warnings; use strict; use Term::ANSIColor; my ($primer, $entered); my $breakout = 0; print "\nPrime numbers between 2 and your entered number.\n\n"; while ($breakout != 1) { print "\nEnter a number: "; $entered = <STDIN>; chomp $entered; print "\n"; if ($entered <= 2) { print "Your number must be greater than 2, try again.\n"; } else { print color('red'); print "Prime numbers between 2 and $entered are: "; print color('reset'); for (my $x = 3; $x <= $entered; $x++) { my $y = 0; my $z = 0; while ($y <= $x) { $y++; if (($x % $y) == 0) { $z++; } } if ($z < 3) { print "$x "; } } print "\n\n"; $breakout = 1; } };

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1159212]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2019-02-22 10:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I use postfix dereferencing ...









    Results (117 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!