PDA

View Full Version : List of prime No.s


habib123456
May 7, 2011, 07:19 AM
Would you please give me list of 400 digit prime numbers?

Unknown008
May 7, 2011, 07:27 AM
Um... is there possibly a good use of those prime numbers?

habib123456
May 7, 2011, 07:34 AM
Yes

Unknown008
May 8, 2011, 01:33 AM
Okay, download the program interpreter for perl, a computer language I'm most at ease with:

Strawberry Perl for Windows (http://strawberryperl.com/)

Then, run in this script:


use strict;
use warnings;

my @primes = (2);
my $L = 400;
my ($number_to_check, $p) = @_;

print "The list of 400 digit prime numbers is: \n";

LOOP:
for ($number_to_check = 3 ; length($number_to_check) < $L+1 ; $number_to_check++)
{
foreach $p (@primes)
{
if ($number_to_check % $p == 0)
{
next LOOP;
}
}
push @primes, $number_to_check;
if (length($number_to_check == 400)
{
print $number_to_check, "/n";
}
}


You should get your list. :)

Otherwise this thread won't be enough to contain all those numbers.

However, since this requires many many numbers, you might have to wait for a long time.

jcaron2
May 10, 2011, 08:05 AM
LMAO! A long, long, long, LONG time.

If you could harness all of the computer power that currently exists on the planet, it would take far, far, FAR longer than the expected lifetime of the universe just to calculate ONE 400-digit prime with that algorithm.

Meanwhile, the list would have approximately 10^397 entries. That's approximately equal to the number of atoms in the known universe... to the FIFTH POWER!

jcaron2
May 10, 2011, 08:15 AM
By the way, here's one:

39746023705334856810141445653508188073263011481730 48126966221182886378065861229010168735817245761305 48679039296322704621648792487421458261235658228983 00322084785886959246326690627903528961627779424396 43491779531866868540351903064575384238649215559076 36955337696989876512738571801178542236563566070769 23835714598659726521078390177300165817971691670348 80152278297771317738806828856468200683593750000001

Unknown008
May 10, 2011, 09:33 AM
Oops, a mistake in my coding: change this line:

Print $number_to_check, "/n";

To:

Print $number_to_check, "\n";

(Note the backslash instead of the slash. /n means it'll print /n while \n means it'll change line. This is better since you don't want your 400 digit number list to get to a ~400 trillion digit number :eek:)

jcaron2
May 10, 2011, 10:54 AM
By the way, Jerry, I hope it was clear that I wasn't criticizing your algorithm; it's a perfectly good one (/n versus \n notwithstanding :) ). I was just amused because, as I'm sure you know, it's just not feasible to find prime numbers that way with more than, say, 20-25 digits. Once you start to get to numbers larger than that, even if you have the computer power to do trillions of operations per second, it could take years or decades or longer to do the calculation for a single number. I think all of the known primes with larger numbers of digits are special cases, such as Weiferich, Mersenne, twin, etc.

By the way, forgetting 400-digit primes, I should point out that you can speed up your algorithm significantly by only checking for divisibility up to the largest prime not greater than the square root of the number you're checking. For example, if you're checking to see if 263 is prime, there's no need to check any prime factors beyond 13. Any prime factors greater than sqrt(263) would have had a corresponding factor which was less than sqrt(263), so if you didn't encounter any prime factors between 2 and 13, you can already be sure there won't be any between 17 and 257 without having to check; you already know the number is prime.

That might not make that much difference for a 3-digit number like 263, but for a 12-digit number it's on the order of a million times faster!

For a 400-digit number, it would be 10^200 times faster, which would be completely irrelevant since the universe would implode long before it ever got anywhere even close. ;)

Unknown008
May 10, 2011, 11:13 AM
Yes, I know, I just took a code I used for projecteuler and chunked other values. I've thought of this when trying to make it faster, but never really remembered to amend this to the code once I got on the computer. I'm either on forums, or working on a trivia, or some other artwork/animations XD

jcaron2
May 10, 2011, 11:30 AM
Somehow I figured you already knew that. :)

How are you doing on Project Euler? I used to keep up with all the latest challenges, but I haven't been there in a while.

Unknown008
May 10, 2011, 11:34 AM
Lol, with all the things, I'm turning down perl to learn some more tcl, though I didn't go through a tutorial as I did with perl. It's mainly for an IRC bot, maybe implement some quick calculation tools, and some fun stuff. I got only 10 done or so :p I didn't get on there for quite some time now... a month I think. :o

habib123456
May 10, 2011, 06:12 PM
Thanks dudes, I knew about Time Complexity and Memory Storage and.. . Because of that I'm searching for a list not calculating of each number.
And also I want to say, there are some algorithms that they are doing fact calculation but they have some gap, it means if they found x as a prime number like ( 23452345... 9856874567351 256 digits) and next prime with 257 digits, we are not sure there any more prime between them or not!!
Actually this a tough topic in world but they are calculating primes for long time back so I think there is list of theme if that is available ;) .
By the way thanks a lot for your suggestions.

jcaron2
May 10, 2011, 06:24 PM
Yeah, I could only find the one 400-digit number, but I agree, there must be a list somewhere. The Prime Pages lists a bunch with 200-300 digits, and, of course, a bunch with 100,000+ digits, but I couldn't find a link to any with 400. I assume you've been down the same road.

I'm glad to know I'm not the only one who gets excited about this kind of stuff. :) I've been working for a while (here and there when I get the opportunity and motivation) on an attempt to prove Goldbach's Conjecture.

jcaron2
May 10, 2011, 06:40 PM
If you feel like spending $10, supposedly you can download a list of 90,000 of them here (http://www.prime-numbers.org/premium.html).

Unknown008
May 11, 2011, 09:42 AM
And to think that people are ready to sell such a list of numbers... =/

I know, someone should buy it, and spread it all over the net! :D
... wait... there would be less than 1% of the whole net who will be actually using that list :(