Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Prime Number Finder

by Anonymous Monk
on Mar 31, 2016 at 17:01 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1159212]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found