## Other

drummers-lowrise

Message boards : General discussion : List of prime numbers

 Subscribe SortOldest firstNewest firstHighest rated posts first
Author Message
A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120192 - Posted: 28 Aug 2018 | 14:41:13 UTC

Hello. Do anyone have the lists of consecutive prime numbers?

Eudy Silva

Joined: 26 Aug 17
Posts: 1543
ID: 918937
Credit: 342,052,559
RAC: 187,826

Message 120193 - Posted: 28 Aug 2018 | 14:46:03 UTC - in response to Message 120192.

For example, "first 1000 primes" shows many hits.
Among them is https://www.di-mgt.com.au/primes1000.html

Edit:
Or do you want something else ?
I might have not understood correctly.
____________
"Accidit in puncto, quod non contingit in anno."
Something that does not occur in a year may, perchance, happen in a moment.

JeppeSN

Joined: 5 Apr 14
Posts: 1534
ID: 306875
Credit: 35,660,505
RAC: 9,493

Message 120194 - Posted: 28 Aug 2018 | 15:04:51 UTC

It depends on what you mean.

You can calculate your own list. If you go to https://pari.math.u-bordeaux.fr/gp.html and type:

primes(100)
[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, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541]

And if you type:
primes([10000000000,10000001000])
[10000000019, 10000000033, 10000000061, 10000000069, 10000000097, 10000000103, 10000000121, 10000000141, 10000000147, 10000000207, 10000000259, 10000000277, 10000000279, 10000000319, 10000000343, 10000000391, 10000000403, 10000000469, 10000000501, 10000000537, 10000000583, 10000000589, 10000000597, 10000000601, 10000000631, 10000000643, 10000000649, 10000000667, 10000000679, 10000000711, 10000000723, 10000000741, 10000000753, 10000000793, 10000000799, 10000000807, 10000000877, 10000000883, 10000000889, 10000000949, 10000000963, 10000000991, 10000000993, 10000000999]

Both are lists of consecutive prime numbers.

/JeppeSN

dukebg
Volunteer tester

Joined: 21 Nov 17
Posts: 241
ID: 950482
Credit: 23,670,125
RAC: 0

Message 120195 - Posted: 28 Aug 2018 | 15:05:42 UTC

If you want "the first N prime numbers" or "all prime numbers up to X", which is indeed something used for sieving (judging that the post is in the Sieving subforum), there's little to no reason to store them explicitly as they are much quicker generated on the fly (sieve of Eratosthenes, sieve of Sundaram, etc.) than read from disk/network. Nevertheless, there are lists of those on the internet, such as this.

Michael Goetz
Volunteer moderator

Joined: 21 Jan 10
Posts: 13648
ID: 53948
Credit: 285,463,897
RAC: 46,203

Message 120196 - Posted: 28 Aug 2018 | 16:01:22 UTC - in response to Message 120192.

Hello. Do anyone have the lists of consecutive prime numbers?

It's important to note that almost nothing at PrimeGrid ever searches for consecutive prime numbers. In general, there's usually about a gazillion primes between any two of the primes in our database.

The only primes that are likely to be consecutive are the small number of twin primes we've found.

As has been noted in the earlier replies, there are lists on the Internet, some with a lot of entries, of very small consecutive primes that you can Google if you wish. Those aren't the kind of primes that PrimeGrid works with.
____________
My lucky number is 75898524288+1

JeppeSN

Joined: 5 Apr 14
Posts: 1534
ID: 306875
Credit: 35,660,505
RAC: 9,493

Message 120199 - Posted: 28 Aug 2018 | 19:39:56 UTC

There are also consecutive primes in arithmetic progression, but apart from twin primes (already mentioned by Michael Goetz) PrimeGrid does not search for them. /JeppeSN

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120220 - Posted: 30 Aug 2018 | 2:25:42 UTC - in response to Message 120195.

For example, "first 1000 primes" shows many hits.
Among them is https://www.di-mgt.com.au/primes1000.html

This is a small list...

It depends on what you mean.
And if you type:
primes([10000000000,10000001000])
...

But if I type
primes([10000000000,10000010000])

i got an error, because client-side JavaScript calculations there...

If you want "the first N prime numbers" or "all prime numbers up to X", which is indeed something used for sieving (judging that the post is in the Sieving subforum), there's little to no reason to store them explicitly as they are much quicker generated on the fly (sieve of Eratosthenes, sieve of Sundaram, etc.) than read from disk/network. Nevertheless, there are lists of those on the internet, such as this.

Last link seems good, but... Only 50 Millions?

I see here: https://primes.utm.edu/nthprime/ using database with 30 trillions... This is good, and I see fast searching N-th prime...
But... There is no consecutive primes lists with this range...

And... How long will be working the fastest algorithm
to sieve prime numbers and get first trillion consecutive primes, for example?

I think will be better to search Nth-prime,
just by using a skip sectors with consecutive primes,
and without invest there many MIPS, FLOPS and time
to check primality for each number...

1 gram DNA can containing 700 Terabytes information, and maybe this space can be filled as consecutive primes.
So I just see, you don't have projects to calculate consecutive primes, and don't have any database, like this:
http://primos.mat.br/

So I think this can be calculated, using molecular dinamycs and molecular computers, like the source of synergy for molecular nano-algorithmics...

dukebg
Volunteer tester

Joined: 21 Nov 17
Posts: 241
ID: 950482
Credit: 23,670,125
RAC: 0

Message 120224 - Posted: 30 Aug 2018 | 14:14:22 UTC - in response to Message 120220.

I see here: https://primes.utm.edu/nthprime/ using database with 30 trillions... This is good, and I see fast searching N-th prime...
But... There is no consecutive primes lists with this range...

There's no reason to make such lists, just like there is no reason to make a list of "first 30 trillion integers".

For an estimation of total time to make such a list, you can check out the description of the algorithm and the function itself that are provided at that link. Determining the bin the number falls into is pretty much instantaneous, so "might take up to 10 seconds" is just a max estimation of time needed to sieve a bin. If you want to sieve everything, you can sieve all bins in parallel, of course.

Michael Goetz
Volunteer moderator

Joined: 21 Jan 10
Posts: 13648
ID: 53948
Credit: 285,463,897
RAC: 46,203

Message 120225 - Posted: 30 Aug 2018 | 14:39:28 UTC

I've moved this thread to "General". The Sieving forum is for discussing our manual sieving projects.
____________
My lucky number is 75898524288+1

JeppeSN

Joined: 5 Apr 14
Posts: 1534
ID: 306875
Credit: 35,660,505
RAC: 9,493

Message 120227 - Posted: 30 Aug 2018 | 15:53:33 UTC - in response to Message 120220.

It depends on what you mean.
And if you type:
primes([10000000000,10000001000])
...

But if I type
primes([10000000000,10000010000])

i got an error, because client-side JavaScript calculations there...

Not sure what JavaScript settings their web interface requires. But the prime "calculation" itself is done at the serverside.

So try with some more liberal JavaScript settings. It works for me. Or better, download PARI/GP yourself and paste that function call into the GP "calculator". Not hard to write from GP to a file on your own machine, in that case.

/JeppeSN

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120250 - Posted: 1 Sep 2018 | 1:16:34 UTC - in response to Message 120220.

http://primos.mat.br/

There is primes between 1-st trillion natural numbers...

https://primesznxlfc5ika.onion.top/primes/indexen.html
Here is primes - up to 2 trillions of natural numbers.

Miller-Rabin algorithm working fastly, and have so low errors percentage even with 10 rounds.
Can this be vectorized to using parralel GPU calculations?

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120281 - Posted: 3 Sep 2018 | 0:06:54 UTC - in response to Message 120250.

http://primos.mat.br/ ā 1-st trillion natural numbers...

Miller-Rabin algorithm working fastly, and have so low errors percentage even with 10 rounds.
Can this be vectorized to using parralel GPU calculations?

I have JavaScript implementation of this algoritm, using BigIntegers
But 10 million primes in browser not convenient to generate.

I cann't see vectorized implementation of this algoritm, as portable EXE for windows, to be able for using GPU calculations...
.cu files from github need to be compiled,
python realization need to install python and Numba, pyCuda, and this not portable...
I see, this primesieve...
But there is "Sieve of Eratosthenes", and this need memory,
and cann't save prime numbers as result in the file - before full generate all...

Your project working with GPU calculations...

So.. Can your programmers, just for fun,
make Miller-Rabin algorithm vectorized - to be able GPU parallelism there (CUDA, OpenCL, etc),
like this portable EXE: http://www.naturalnumbers.org/primes.html#generator

I see portable GPU programs, with cuda calculations,
like ccminer-x64.exe (portable GPU miner), vanitygen.exe (vanity bitcoin address generator),
scallion.exe (vanity onion-domain for TOR), etc...
All this programs are portable and working with GPU devices!..

JeppeSN

Joined: 5 Apr 14
Posts: 1534
ID: 306875
Credit: 35,660,505
RAC: 9,493

Message 120284 - Posted: 3 Sep 2018 | 5:52:05 UTC - in response to Message 120281.

With the danger of repeating myself, if you want 10 million primes in a file, with PARI/GP you just type

write("myPrimeList.txt", primes(10^7))
/JeppeSN

x3mEn

Joined: 21 Jul 10
Posts: 353
ID: 64131
Credit: 63,148,858
RAC: 2,362

Message 120285 - Posted: 3 Sep 2018 | 9:40:05 UTC

Consecutive List Of Primes, 1.02 (Windows 64-bit) Copyright 2018, Alexander Belogourov aka x3mEn Command line parameters : 1 22801763489 -p -f 1000000 Number range borders : from 3 to 22801763489 step 2 Total amount of Numbers : 11400881744 Factoring Block Size : 1000000 Starting date timestamp : 03.09.2018 12:25:03 Elapsed time : 00:04:53.125 Total amount of Primes : 1000000000

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120289 - Posted: 3 Sep 2018 | 12:04:12 UTC - in response to Message 120285.

Consecutive List Of Primes, 1.02 (Windows 64-bit) Copyright 2018, Alexander Belogourov aka x3mEn Command line parameters : 1 22801763489 -p -f 1000000 Number range borders : from 3 to 22801763489 step 2 Total amount of Numbers : 11400881744 Factoring Block Size : 1000000 Starting date timestamp : 03.09.2018 12:25:03 Elapsed time : 00:04:53.125 Total amount of Primes : 1000000000

What is this? Where is this?

As I said, I have consecutive prime numbers, up to 2 trillions of natural numbers.
This is containing 73,301,896,139 prime numbers total, and last prime number is 1,999,999,999,981.

With the danger of repeating myself, if you want 10 million primes in a file, with PARI/GP you just type
write("myPrimeList.txt", primes(10^7))
/JeppeSN

Hehheh... I never not used this program and don't read the documentation...
write("myPrimeList.txt", primes(10^7))

But I see the error:
*** at top-level: write("myPrimeList.txt",primes(10^7))
*** ^-------------
*** primes: the PARI stack overflows !
current stack size: 8000000 (7.629 Mbytes)
[hint] set 'parisizemax' to a non-zero value in your GPRC

write("myPrimeList.txt", primes(10^6))

Tell me this error too.
write("myPrimeList.txt", primes(10^5))

write("myPrimeList.txt", primes([10000000000,10000010000]))[/quote]
All was been writed successfully... But small range...
write("myPrimeList.txt", primes([2000000000000,2000001000000]))

ERROR.
write("myPrimeList.txt", primes([2000000000000,2000000900000]))

success, but small range...
No one from this examples not tell me consecutive 10M primes...
And I'm not sure what the calculations is made on the GPU...

I'm still confident that the better way to generate consecutive prime numbers - there would be
a compact and portable CUDA-compatible program (like PrimeGen.exe),
with a vectorized and paralleled, this small Miller-Rabin algorithm.

Also, I published the good commented python code of Miller-Rabin generator - here.
This working only on 1 CPU core... No multiprocessing, multithreading, vectorization and parallelizm... =(

Using this code, anyone can make calculation any part of "2T-3T", and upload this on my server.
There is available FOLDER_FOR_UPLOADS in the root directory of the server.
You can drop there a torrent-file, for example.

x3mEn

Joined: 21 Jul 10
Posts: 353
ID: 64131
Credit: 63,148,858
RAC: 2,362

Message 120290 - Posted: 3 Sep 2018 | 13:08:33 UTC

Consecutive List Of Primes, 1.02 (Windows 64-bit) Copyright 2018, Alexander Belogourov aka x3mEn Command line parameters : 2000000000000 2001000000000 -o -p -f 10000000 Number range borders : from 2000000000001 to 2000999999999 step 2 Total amount of Numbers : 500000000 Factoring Block Size : 10000000 Starting date timestamp : 03.09.2018 15:54:39 Elapsed time : 00:00:28.132 Total amount of Primes : 35303851 2000000000003 2000000000123 2000000000137 2000000000153 2000000000179 ... 2000999999891 2000999999903 2000999999909 2000999999939 2000999999951

What is this?

I said "Ok, the challenge accepted" and yesterday had wrote the application (to be honest, not from the scratch).

Where is this?

I published the project in Github here.
You can use it at your own risk, but remember, the code is not verified so may contain mistakes.

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120291 - Posted: 3 Sep 2018 | 13:36:41 UTC - in response to Message 120290.

I published the project in Github here.

I see there is only .c and .cbp file... Do you have compiled portable exe? Can you publish this in releases, as a zip archive?

You can use it at your own risk, but remember, the code is not verified so may contain mistakes.

Not problem, I can re-check results from this generator again...
But if this program not have multithreading, multiprocessing
or if code not vectorized to supporting parallel GPU calculations,
so no make any sense to compile and use this,
because my published python-Miller-rabin generator
working not a slowly even on 1 CPU core...

x3mEn

Joined: 21 Jul 10
Posts: 353
ID: 64131
Credit: 63,148,858
RAC: 2,362

Message 120292 - Posted: 3 Sep 2018 | 13:51:55 UTC - in response to Message 120291.

But if this program not have multithreading, multiprocessing
or if code not vectorized to supporting parallel GPU calculations

Excuse, you're asking a liitle too much.

JeppeSN

Joined: 5 Apr 14
Posts: 1534
ID: 306875
Credit: 35,660,505
RAC: 9,493

Message 120294 - Posted: 3 Sep 2018 | 15:47:30 UTC - in response to Message 120289.

Hehheh... I never not used this program and don't read the documentation...
write("myPrimeList.txt", primes(10^7))

But I see the error:
*** at top-level: write("myPrimeList.txt",primes(10^7))
*** ^-------------
*** primes: the PARI stack overflows !
current stack size: 8000000 (7.629 Mbytes)
[hint] set 'parisizemax' to a non-zero value in your GPRC

That hint is good. The stack size of 8 million bytes is insufficient, so you want to allow PARI to increase its own stack. To do it in just this session, you can type
default(parisizemax, 6G)

which will allow PARI to increase its own stack size, but never to more than 6 billion bytes. Same as default(parisizemax, 6*10^9).

After that you can run write("myPrimeList.txt",primes(10^7)) as I suggested.

If you want to set parisizemax automatically, you can edit the "GPRC" file. It is shown at startup which file that is, but it may be:
C:\Program Files (x86)\Pari64-2-11-0\gprc.txt

depending on your OS and installation folder. Edit the file with a text editor (like Notepad) which is "Run as administrator". Insert these lines, for example:
parisizemax = 6G primelimit = 100M

The primelimit thing in the GPRC file will determine the size of a pre-calculated list of primes the PARI uses for some purposes.

/JeppeSN

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120295 - Posted: 3 Sep 2018 | 15:52:15 UTC - in response to Message 120289.

repeating myself, if you want 10 million primes in a file,
with PARI/GP
you just type
write("myPrimeList.txt", primes(10^7))
/JeppeSN

write("myPrimeList.txt", primes(10^7))

But I see the error:
*** at top-level: write("myPrimeList.txt",primes(10^7))
*** ^-------------
*** primes: the PARI stack overflows !
current stack size: 8000000 (7.629 Mbytes)
[hint] set 'parisizemax' to a non-zero value in your GPRC

write("myPrimeList.txt", primes(10^6))

Tell me this error too.
write("myPrimeList.txt", primes(10^5))

write("myPrimeList.txt", primes([10000000000,10000010000]))
All was been writed successfully... But small range...
write("myPrimeList.txt", primes([2000000000000,2000001000000]))

ERROR.
write("myPrimeList.txt", primes([2000000000000,2000000900000]))

success, but small range...
No one from this examples not tell me consecutive 10M primes...
And I'm not sure what the calculations is made on the GPU...

I did solve the problem with stack overflows by using command:
allocatemem(2^28)
*** allocatemem: Warning: new stack size = 268435456 (256.000 Mbytes).

Then, available the command:
write("myPrimeList.txt", primes([2000000000000,2000030000000]))

Without any errors...

But, inside the file, there is a prime numbers in one row.
Can I specify delimiters for rows,
delimiter between prime numbers in the row,
and number of primes in one row??

default(parisizemax, 6G)

C:\Program Files (x86)\Pari64-2-11-0\gprc.txt

parisizemax = 6G primelimit = 100M

This not working without
allocatemem(2^28)...

write("myPrimeList.txt", primes([2000000000000,2000030000000]))

*** primes: Warning: increasing stack size to 16000000.
*** primes: Warning: increasing stack size to 32000000.
*** primes: Warning: increasing stack size to 64000000.
*** primes: Warning: increasing stack size to 128000000.
*** primes: Warning: increasing stack size to 256000000.
*** primes: Warning: increasing stack size to 512000000.

And after run
allocatemem(2^28)...

I see the same errors, but file is generating...

Also, I want to using sapararors, like there is in this file
10 prime numbers in row through TAB, then new string...
Is this possible by using PARI/GP??

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120296 - Posted: 3 Sep 2018 | 17:06:17 UTC - in response to Message 120294.

Hm... I cann't write allocatemem(2^30) in gprc.txt
so I using next way to fix errors...

This way is a four consecutive commands:

gp > allocatemem(2^30)
*** Warning: new stack size = 1073741824 (1024.000 Mbytes).
gp > default(parisizemax, 6G)
*** Warning: new maximum stack size = 6000000000 (5722.046 Mbytes).
gp > default(primelimit, 400M)
gp > write("myPrimeList.txt", primes([2000000000000,2000040000000]))
gp >

And no any errors then...
Each 10 million of prime numbers, in range [2 trillions - 3 trillions]
are contains in range between 300M natural numbers,
so 400 millions can be can be enough for finding this all...

But... What about separators in PARI/GP?? '\t' and '\r\n' need to using in txt file...

JeppeSN

Joined: 5 Apr 14
Posts: 1534
ID: 306875
Credit: 35,660,505
RAC: 9,493

Message 120299 - Posted: 3 Sep 2018 | 19:45:45 UTC - in response to Message 120295.

This is not a GPU app. It will not use the GPU.

10 prime numbers in row through TAB, then new string...
Is this possible by using PARI/GP??

You can write programs in PARI/GP. Here is a primitive program:
n=0;s="";forprime(p=10^6,10^7,n++;s=Str(s,p,if(n % 10 != 0,"\t","\n"));if(n % 10^3 == 0, write1("myFile.txt",s);s=""));write("myFile.txt",s)

It will iterate through all primes between 10^6 and 10^7, counting them with n. The variable s is a string that is built with TAB, or every tenth time with NEWLINE. For every 10^3 number, s is appended to file "myFile.txt" and s is reset. This program is slow and spends all the time with string operations and file operations. You can probably do it in a better way.

Your issues with parisizemax I do not understand. The intended meaning is that if parisizemax is e.g. 6000000000, then PARI will increase its own stack "on the fly", when needed, writing "Warning: increasing stack size to ..." in red, but going on with its tasks. Only if a size over 6 billion (in this example) is needed, will an error be issued.

/JeppeSN

Eudy Silva

Joined: 26 Aug 17
Posts: 1543
ID: 918937
Credit: 342,052,559
RAC: 187,826

Message 120300 - Posted: 3 Sep 2018 | 20:39:31 UTC

A_H_O_H, have you seen this ?

https://primesieve.org/

primesieve is a free software program and C/C++ library that generates primes using a highly
optimized sieve of Eratosthenes implementation. It counts the primes below 10^10 in just
0.45 seconds on an Intel Core i7-6700 CPU (4 x 3.4 GHz). primesieve can generate primes
and prime kātuplets up to 2^64."
____________
"Accidit in puncto, quod non contingit in anno."
Something that does not occur in a year may, perchance, happen in a moment.

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120301 - Posted: 3 Sep 2018 | 22:45:59 UTC - in response to Message 120299.

This is not a GPU app. It will not use the GPU.

Ok, but there is multiprocessing and multithreading.
So this PARI/GP prime generator really working faster.

10 prime numbers in row through TAB, then new string...
Is this possible by using PARI/GP??

You can write programs in PARI/GP. Here is a primitive program:
n=0;s="";forprime(p=10^6,10^7,n++;s=Str(s,p,if(n % 10 != 0,"\t","\n"));if(n % 10^3 == 0, write1("myFile.txt",s);s=""));write("myFile.txt",s)

Nice! Thanks! Your idea to write each 1000 primes using write1 function is very good.
I don't see stack overflows errors in this case,
and no need to using allocatemem(2^30), default(parisizemax, 6G) and default(primelimit, 400M)

So I did write this:
folder="C:\\Python Portable\\PariGPprimes";blockname="2T-3T";part=1;n=0;s="";forprime(p=2000000000000,3000000000000,n++;s=Str(s,p,if(n % 10 != 0,"\t","\n"));if(n % 10^3 == 0, write1(Str(folder,"\\",blockname,"_part",part,".txt"),s);s="");if(n%10000000==0, part++));

and this 7z.bat to zip all txt-files:
for %%X in ("C:\Python Portable\PariGPprimes\*.txt") do "C:\Program Files\7-Zip\7z.exe" a "%%~nX.7z" "%%X"

I have still runned Miller-Rabin generator on python too, and I'll see that's working slowly...
So I'll unpack all txt parts - after compare hashes, using portable MultiHasher 2.9.
[/quote]

Your issues with parisizemax I do not understand.
The intended meaning is that if parisizemax is e.g. 6000000000, then PARI will increase its own stack "on the fly",
when needed, writing "Warning: increasing stack size to ..." in red, but going on with its tasks.
Only if a size over 6 billion (in this example) is needed, will an error be issued.

Ok, just I saw stack overflows errors
when allocatemem(2^30) was not been inserted before commands:
default(parisizemax, 6G) and default(primelimit, 400M)
but program really continued working and successfully finished.
And even there was been an errors, I got full file, using command:
write("myPrimeList.txt", primes([2000000000000,2000040000000]))

A_H_O_H, have you seen this ?
https://primesieve.org/

Yea, I saw, this is compact program without GPU supporting, and this working fastly...
But... I don't see there an option, to write primes in the file directly, or partial,
like here, using PARI/GP (each 1000 primes)...

I did try to generate 10M primes there, and I see need to wait this.
Maybe all primes go to RAM and contains here before finishing generate process. :D

Eudy Silva

Joined: 26 Aug 17
Posts: 1543
ID: 918937
Credit: 342,052,559
RAC: 187,826

Message 120302 - Posted: 4 Sep 2018 | 1:13:21 UTC - in response to Message 120301.

A_H_O_H wrote:
... But... I don't see there an option, to write primes in the file directly, or partial ...

One way is to use the console version, with the corresponding parameter to print the primes and redirect the output to a file:

primesieve 10e6 -p > primes.txt

____________
"Accidit in puncto, quod non contingit in anno."
Something that does not occur in a year may, perchance, happen in a moment.

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120310 - Posted: 4 Sep 2018 | 15:13:04 UTC - in response to Message 120302.

[quote]

A_H_O_H wrote:

primesieve 10e6 -p > primes.txt

Any delimiters can be specified?

Eudy Silva

Joined: 26 Aug 17
Posts: 1543
ID: 918937
Credit: 342,052,559
RAC: 187,826

Message 120311 - Posted: 4 Sep 2018 | 15:30:42 UTC - in response to Message 120310.

primesieve.exe --help Usage: primesieve [START] STOP [OPTION]... Generate the primes and/or prime k-tuplets inside [START, STOP] (< 2^64) using the segmented sieve of Eratosthenes. Options: -c[N+], --count[=N+] Count primes and prime k-tuplets, N <= 6, e.g. -c1 primes, -c2 twins, -c3 triplets, ... --cpu-info Print CPU information -d<N>, --dist=<N> Sieve the interval [START, START + N] -h, --help Print this help menu -n, --nth-prime Calculate the nth prime, e.g. 1 100 -n finds the 1st prime > 100 --no-status Turn off the progressing status -p[N], --print[=N] Print primes or prime k-tuplets, N <= 6, e.g. -p1 primes, -p2 twins, -p3 triplets, ... -q, --quiet Quiet mode, prints less output -s<N>, --size=<N> Set the sieve size in KiB, N <= 4096 -t<N>, --threads=<N> Set the number of threads, N <= CPU cores --time Print the time elapsed in seconds -v, --version Print version and license information Examples: primesieve 1000 Count the primes below 1000 primesieve 1000 -c2 Count the twin primes below 1000 primesieve 1e6 -p Print the primes below 10^6 primesieve 100 200 -p Print the primes inside [100, 200]

____________
"Accidit in puncto, quod non contingit in anno."
Something that does not occur in a year may, perchance, happen in a moment.

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120313 - Posted: 4 Sep 2018 | 16:14:37 UTC - in response to Message 120311.

I did try -help too, and don't see any delimiters to specify there.
I can rebuild txt files, using python, but this program using CPU calculations.

Eudy Silva

Joined: 26 Aug 17
Posts: 1543
ID: 918937
Credit: 342,052,559
RAC: 187,826

Message 120316 - Posted: 4 Sep 2018 | 16:35:51 UTC - in response to Message 120313.

I believe that START and STOP might do what you want.
(I haven't tried it.)

primesieve 100 200 -p Print the primes inside [100, 200]
____________
"Accidit in puncto, quod non contingit in anno."
Something that does not occur in a year may, perchance, happen in a moment.

x3mEn

Joined: 21 Jul 10
Posts: 353
ID: 64131
Credit: 63,148,858
RAC: 2,362

Message 120317 - Posted: 4 Sep 2018 | 16:55:25 UTC

try

primesieve 10e6 -p | sed -r 's/\, |\[|\]/\n/g' | tail -n +2 | head -n -1 > primes.txt

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120318 - Posted: 4 Sep 2018 | 16:59:55 UTC - in response to Message 120317.

try
primesieve 10e6 -p | sed -r 's/\, |\[|\]/\n/g' | tail -n +2 | head -n -1 > primes.txt

Incorrect sed.

x3mEn

Joined: 21 Jul 10
Posts: 353
ID: 64131
Credit: 63,148,858
RAC: 2,362

Message 120322 - Posted: 4 Sep 2018 | 19:15:58 UTC - in response to Message 120318.

Incorrect sed.

tail and head are also bash utils, you can also download them or skip at all, they were inserted just to remove excess line breaks.

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120327 - Posted: 4 Sep 2018 | 22:46:49 UTC

So, the best way now, to generate the txt-parts, like there is on http://primos.mat.br
is this way:

2. Install this.
3. Run gp.exe with administrator permissions.
4. Switch keyboard layout to english (EN)
5. paste this code there (one string!):

folder="C:\\Pari64-2-11-0\\data";blockname="2T-3T";part=424;n=0;s="";forprime(p=2119935706183,3000000000000,n++;s=Str(s,p,if(n % 10 != 0,"\t","\n"));if(n % 10^3 == 0, write1(Str(folder,"\\",blockname,"_part",part,".txt"),s);s="");if(n%10000000==0, part++));

6.
In this string need to set two parameters - number of the part and first prime p.
Fist prime can be calulated fastly, because PrimePi(2T) = 73,301,896,139, and +10 millions primes in each part.
So (73,301,896,139+1) + (424-1)*10,000,000 = 73,301,896,140 + 4,230,000,000 = 77531896140 - and this is first prime N for the part 424.
Then, can be available N-th prime here: https://primes.utm.edu/nthprime/index.php?n=77531896140
and this have the value 2,119,935,706,183 (2119935706183).
So this prime number, as result can be used as start prime p for any another part.

As result from start part can be generated many parts.
Each part contains 10M primes,
10 primes in row through '\t' delimiter (0x09),
and 1 million string in each part, through delimiter '\n' (0x0d, 0x0a).

To fast pack many parts in txt format -> to archive, using 7z, can be used a bat-file, with code:
for %%X in ("full_patheway_for_folder_with_txt_parts\*.txt") do "full_pathway_to_7z_folder\7z.exe" a "%%~nX.7z" "%%X"

In this case will be generated many 7z archives near all txt-parts.

After all this work can be paralleled, using many computers and processors,
with comparation of the hashes for the parts.

Pari/GP return me the parts with equal SHA512 hashes (this was been compared with parts generated by my python scrypt),
but PARI/GP generate parts faster. This is not GPU program and using CPU.
__________________________________________________________________________
After all, I want to ask next...
Guys, is there any ways to effective compress prime numbers, without less data?
I think about using Prime gap's + Huffman coding
but if need to search n-th prime, in this case need to sum all previous gaps in the part,
and maybe in all previous parts...
So was been decided to leave prime numbers as packed lists with readable text,
without optimize this to search N-th prime...

A_H_O_H

Joined: 9 Apr 17
Posts: 25
ID: 819725
Credit: 11,857,204
RAC: 0

Message 120736 - Posted: 24 Sep 2018 | 23:25:17 UTC - in response to Message 120290.

Consecutive List Of Primes, 1.02 (Windows 64-bit) Copyright 2018, Alexander Belogourov aka x3mEn

Consecutive List Of Primes, 1.02 (Windows 64-bit) Copyright 2018, Alexander Belogourov aka x3mEn

What is this?

I said "Ok, the challenge accepted" and yesterday had wrote the application (to be honest, not from the scratch).

Where is this?

I published the project in Github here.

You can use it at your own risk, but remember, the code is not verified so may contain mistakes.

Nice program, fast generation.
Here is modified .c and compiled .exe
You can see changes.txt, comments in the source code,
and do with this code what do you want.
Maybe this can be optimized to working faster,
but this works fine for me (win32 version).

I think about generating many archives with half prime gaps, and then store and hashing this.
Maybe all primes from 0 to 30 Trillions can be saved in the space ~30 x 3500 x 7MBytes,
because prime gap between primes is even number, not big (sometimes)
and this can be saved as one byte, if this will be divided by 2.
In this case each part with 10M primes have only ~10 MBytes and ~6.4Mbytes if this 7z packed.
In trillion range of natural numbers there is ~35 billions primes ~3500 archives. So 1 TB can store all primes up to 30 trillions.

Also can be writted converter between some formats, as the function, inside the program.

Best regards, and have a nice day.

Message boards : General discussion : List of prime numbers