APM: Perl Challenge

Evan Harris eharris at puremagic.com
Sun Mar 23 15:15:29 CST 2003


I'm more interested in why I get a Segmentation fault after 7057.

7027 is prime
7039 is prime
7043 is prime
7057 is prime
Segmentation fault

:)

Evan


On Sun, 23 Mar 2003, Wayne Walker wrote:

> Please don't reply to the list!
>
> Below is a program with a regex that tests for prime numbers.  I'll buy
> dinner at PokeJo's before the next meeting for the first person to send
> me a description of how it works.  I'm assuming anyone who has seen this
> before won't try to get the prize.  Next Monday I'll post the correct
> answers I got and who sent them.  That email will have appropriate
> subject to allow those still working on the problem to not accidentally
> see the answer.
>
> No, I did not come up with the regex.  It's attributed to an Abigail
> (aparently of the Athens Perl Mongers, but not certain).
>
> The coupe de graz will be to also describe the function of time versus
> the change in $i's max value (e.g. "if we search 1-200 instead of 1-100,
> it takes 1024 times as long to run, meaning that the ratio function is
> k * (i2/i1)^10).
>
> #!/usr/bin/perl
>
> foreach $i (1..100)
> {
> 	if ((1 x $i) !~ /^1?$|^(11+?)\1+$/)
> 	{
> 		print "$i is prime\n";
> 		$j = $i;
> 	}
> }
>
> --
>
> Wayne Walker
>
> www.broadq.com :)  Bringing digital video and audio to the living room
> _______________________________________________
> Austin mailing list
> Austin at mail.pm.org
> http://mail.pm.org/mailman/listinfo/austin
>




More information about the Austin mailing list