CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [BillKSmith] beginner prime number script: Edit Log



FishMonger
Veteran / Moderator

Feb 14, 2013, 12:35 PM


Views: 1055
Re: [BillKSmith] beginner prime number script

As long as we're providing the answer to someones homework assignment, we might as well provide a more efficient module solution.


Code
#!/usr/bin/perl 

use strict;
use warnings;
use Math::Prime::XS qw(primes);

my $upper_limit = shift || 100;
print "$_\n" for primes( $upper_limit );


c:\testing>primes.pl
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97


(This post was edited by FishMonger on Feb 14, 2013, 12:37 PM)


Edit Log:
Post edited by FishMonger (Veteran) on Feb 14, 2013, 12:37 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives