let a = 2^256+230191 . this number is the first safe prime larger than 2^256. no justification for choosing a safe prime instead of a regular prime (2^256+297): it seemed like a good idea at the time.
choose b an integer between 1 and 2^256, for example, by SHA256 hashing your favorite string and adding 1.
then, the arithmetic sequence S(n) = a*n + b is your personal slice of the integers, indexed by integer n. we added 1 when choosing b to avoid the sequence being multiples of "a" when b=0. (but congratulations if you've found a preimage of the all-zeroes SHA256 hash.) in contrast to SHA256 just giving you just a single personal integer, you now have an infinite sequence of integers.
by Dirichlet's theorem on arithmetic progressions, every slice contains infinitely many primes.
here are the indices of the first few primes when b = 1:
? b=1; for(i=0,5000, n=a*i+b; if(ispseudoprime(n), print1(" ",i)))
318 1058 1080 1158 1638 1788 2078 2124 2586 2738 2796 2814 2954 2984 3110 3156 3524 3746 3786 3894 3944 4058 4236 4356 4494 4734 4938
here are the indices of the first few primes when b = 10^77 (the largest power of 10 less than 2^256):
? b=10^77; for(i=0,5000, n=a*i+b; if(ispseudoprime(n), print1(" ",i)))
129 299 369 581 701 717 837 999 1221 1281 1569 1661 2181 2289 2543 2613 2637 2679 2871 2903 3053 3479 3497 3551 3741 3899 4109 4509
we randomly found a value of b that takes 3148 terms before it yields its first prime:
? b = 53096783965645552594639935639763204840434333167837603907095024818590142981557; for(i=0,5000, n=a*i+b; if(ispseudoprime(n), print1(" ",i)))
3148 3176 3290 3548 3722 3772 3896 4136 4190 4468 4522 4702
searching methodically from b = 1, records for longest wait until a prime:
? firstindex(b)=my(i,n); for(i=0,+oo, n=a*i+b; if(ispseudoprime(n), return(i)))
? p=0; for(b=0, +oo, x=firstindex(b); if(x>=p, p=x; print(b" "p)))
0 1
1 318
44 327
48 505
54 899
232 983
460 1101
681 1204
1849 1284
2443 1388
3842 1587
8398 2049
79461 2224
173490 2459
197278 2537
4298528 2559
6483858 2597
6911839 2846
15206955 3026
21251536 3159
30848141 3526
? b=30848141; for(i=0,5000, n=a*i+b; if(ispseudoprime(n), print1(" ",i)))
3526 3834 3864 3894 3904 4246 4606 4674 4786 4848 4900 4938
log(a) ~= 177, and log(a*3000) ~= 185, so for typical b, we expect the first prime within about 180 terms (Prime Number Theorem).
not sure what having your own integer sequence would be useful for.
one could slice one sequence itself into (say) 2^256 further slices by indexing not by n=0,1,2,... but by n(m) = a*m + c, m=0,1,2,..., where c is the sub-slice number between 1 and 2^256. reusing "a" avoids creating sequences that are all composites. by repeatedly slicing, perhaps just for c betwen 2^256+1 and a-1 , one can construct an infinite collection of arithmetic sequences (for when 2^256 is not enough), each with an infinite number of primes. we explore this further in future post mikalfpq.
if, instead of being a prime, "a" were a primorial, then, if b and a share no factors (gcd =1), sequences will be much denser in primes. however, if b is not coprime to a, all elements will be composite. therefore, to have primes, one cannot choose b uniformly at random. instead, randomly choose nonzero remainders modulo each of the prime factors of a, then use the Chinese Remainder Theorem to generate a random coprime b. 197# (the product of the first 45 primes) (265 bits) is the first primorial which offers more than 2^256 choices of coprime b, offering about 2^261.1 (product of p-1).
No comments :
Post a Comment