Segmentation fault in Perl grep
I'm working on Euler problem #3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143? here is my Perl code just try to get all the factors first but it got segmentation fault, my Perl age is just about 2 month, could not figure out why. Segmentation fault 11 when I run it. #!/usr/bin/perl use warnings; use strict; my $number = 600851475143; my @factors = grep {$number % $_ == 0} (1..$number); print @factors; Run it again with sudo, no more segmentation fault but nothing printed out.
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.