|
Search: id:A098591
|
|
|
| A098591 |
|
Primality information for the numbers in an interval (k*30,(k+1)*30) packed into one byte using the fact that only numbers = 1, 7, 11, 13, 17, 19, 23, 29 mod 30 can be prime. |
|
+0 2
|
|
| 223, 239, 126, 182, 219, 61, 249, 213, 79, 30, 243, 234, 166, 237, 158, 230, 12, 211, 211, 59, 221, 89, 165, 106, 103, 146, 189, 120, 30, 166, 86, 86, 227, 173, 45, 222, 42, 76, 85, 217, 163, 240, 159, 3, 84, 161, 248, 46, 253, 68, 233, 102, 246, 19, 58, 184, 76
(list; graph; listen)
|
|
|
OFFSET
|
1,1
|
|
|
COMMENT
|
This sequence illustrates an efficient method to store all prime numbers up to some moderate limit. With this method all prime numbers < 2^31 can be stored in a 70 MByte file.
|
|
LINKS
|
Hugo Pfoertner, Generation of a file with packed primes. FORTRAN program.
Hugo Pfoertner, Primality testing using a packed lookup table. FORTRAN program.
Hugo Pfoertner, Programs to generate and access a packed prime lookup table. Executable programs and source code..
|
|
FORMULA
|
a(n)=sum_{k=0..7} (2^k)*isprime(30*n+offset(k)), where isprime(x)=1 for x prime, else 0, and offset(k)={1, 7, 11, 13, 17, 19, 23, 29} for k=0, .., 7.
|
|
EXAMPLE
|
a(1)=223: From the list of prime candidates between 30 and 60 only the number 49 is composite. Therefore a(1)=2^0 (representing 30+1) + 2^1 (representing 30+7) + 2^2 (representing 30+11) + 2^3 (representing 30+13) + 2^4 (representing 30+17) + 2^6 (representing 30+23) + 2^7 (representing 30+29) = 1+2+4+8+16+64+128 = 223.
a(17): There are 2 primes in the interval (17*30,17*30+30)=(510,540): 521=11 mod 30, 523=13 mod 30. Therefore a(17)=2^2 (representing 510+11) + 2^3 (representing 510+13) = 4+8=12.
|
|
PROGRAM
|
Links to FORTRAN source code and executable programs to create the resulting binary file and to use it for extremely fast primality testing are provided.
|
|
CROSSREFS
|
Cf. A000040 prime numbers, A006880 number of primes < 10^n, A098592 number of primes in itervals (30*k, 30*(k+1)).
Sequence in context: A105982 A100607 A092623 this_sequence A142386 A102950 A118818
Adjacent sequences: A098588 A098589 A098590 this_sequence A098592 A098593 A098594
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
Hugo Pfoertner (hugo(AT)pfoertner.org), Sep 16 2004
|
|
|
Search completed in 0.002 seconds
|