Generation of primes

In computational number theory, a variety of algorithms make it possible to generate prime numbers efficiently. These are used in various applications, for example hashing, public-key cryptography, and search of prime factors in large numbers.

For relatively small numbers, it is possible to just apply trial division to each successive odd number. Prime sieves are almost always faster. Prime sieving is the fastest known way to deterministically enumerate the primes. There are some known formulas that can calculate the next prime but there is no known way to express the next prime in terms of the previous primes. Also, there is no effective known general manipulation and/or extension of some mathematical expression (even such including later primes) that deterministically calculates the next prime.

Prime sieves

A prime sieve or prime number sieve is a fast type of algorithm for finding primes. There are many prime sieves. The simple sieve of Eratosthenes (250s BCE), the sieve of Sundaram (1934), the still faster but more complicated sieve of Atkin[1] (2003), sieve of Pritchard (1979), and various wheel sieves[2] are most common.

A prime sieve works by creating a list of all integers up to a desired limit and progressively removing composite numbers (which it directly generates) until only primes are left. This is the most efficient way to obtain a large range of primes; however, to find individual primes, direct primality tests are more efficient[citation needed]. Furthermore, based on the sieve formalisms, some integer sequences (sequence A240673 in the OEIS) are constructed which also could be used for generating primes in certain intervals.

Large primes

For the large primes used in cryptography, provable primes can be generated based on variants of Pocklington primality test,[3] while probable primes can be generated with probabilistic primality tests such as the Baillie–PSW primality test or the Miller–Rabin primality test. Both the provable and probable primality tests rely on modular exponentiation. To further reduce the computational cost, the integers are first checked for any small prime divisors using either sieves similar to the sieve of Eratosthenes or trial division.

Integers of special forms, such as Mersenne primes or Fermat primes, can be efficiently tested for primality if the prime factorization of p − 1 or p + 1 is known.

Complexity

The sieve of Eratosthenes is generally considered the easiest sieve to implement, but it is not the fastest in the sense of the number of operations for a given range for large sieving ranges. In its usual standard implementation (which may include basic wheel factorization for small primes), it can find all the primes up to N in time while basic implementations of the sieve of Atkin and wheel sieves run in linear time . Special versions of the Sieve of Eratosthenes using wheel sieve principles can have this same linear time complexity. A special version of the Sieve of Atkin and some special versions of wheel sieves which may include sieving using the methods from the Sieve of Eratosthenes can run in sublinear time complexity of . Note that just because an algorithm has decreased asymptotic time complexity does not mean that a practical implementation runs faster than an algorithm with a greater asymptotic time complexity: If in order to achieve that lesser asymptotic complexity the individual operations have a constant factor of increased time complexity that may be many times greater than for the simpler algorithm, it may never be possible within practical sieving ranges for the advantage of the reduced number of operations for reasonably large ranges to make up for this extra cost in time per operation.

Some sieving algorithms, such as the Sieve of Eratosthenes with large amounts of wheel factorization, take much less time for smaller ranges than their asymptotic time complexity would indicate because they have large negative constant offsets in their complexity and thus don't reach that asymptotic complexity until far beyond practical ranges. For instance, the Sieve of Eratosthenes with a combination of wheel factorization and pre-culling using small primes up to 19 uses time of about a factor of two less than that predicted for the total range for a range of 1019, which total range takes hundreds of core-years to sieve for the best of sieve algorithms.

The simple naive "one large sieving array" sieves of any of these sieve types take memory space of about , which means that 1) they are very limited in the sieving ranges they can handle to the amount of RAM (memory) available and 2) that they are typically quite slow since memory access speed typically becomes the speed bottleneck more than computational speed once the array size grows beyond the size of the CPU caches. The normally implemented page segmented sieves of both Eratosthenes and Atkin take space plus small sieve segment buffers which are normally sized to fit within the CPU cache; page segmented wheel sieves including special variations of the Sieve of Eratosthenes typically take much more space than this by a significant factor in order to store the required wheel representations; Pritchard's variation of the linear time complexity sieve of Eratosthenes/wheel sieve takes space. The better time complexity special version of the Sieve of Atkin takes space . Sorenson[4] shows an improvement to the wheel sieve that takes even less space at for any . However, the following is a general observation: the more the amount of memory is reduced, the greater the constant factor increase in the cost in time per operation even though the asymptotic time complexity may remain the same, meaning that the memory-reduced versions may run many times slower than the non-memory-reduced versions by quite a large factor.

See also

References

  1. ^ Atkin, A.; Bernstein, D. J. (2004). "Prime sieves using binary quadratic forms" (PDF). Mathematics of Computation. 73 (246): 1023–1030. Bibcode:2004MaCom..73.1023A. doi:10.1090/S0025-5718-03-01501-1.
  2. ^ Pritchard, Paul (1994). Improved Incremental Prime Number Sieves. Algorithmic Number Theory Symposium. pp. 280–288. CiteSeerX 10.1.1.52.835.
  3. ^ Plaisted D. A. (1979). "Fast verification, testing, and generation of large primes". Theor. Comput. Sci. 9 (1): 1–16. doi:10.1016/0304-3975(79)90002-1.
  4. ^ Sorenson, J. P. (1998). "Trading Time for Space in Prime Number Sieves". Algorithmic Number Theory. Lecture Notes in Computer Science. Vol. 1423. pp. 179–195. CiteSeerX 10.1.1.43.9487. doi:10.1007/BFb0054861. ISBN 978-3-540-64657-0.

Read other articles:

Nama ini menggunakan cara penamaan Spanyol: nama keluarga pertama atau paternalnya adalah Gutiérrez dan nama keluarga kedua atau maternalnya adalah Galaviz. Érick Gutiérrez Informasi pribadiNama lengkap Érick Gabriel Gutiérrez Galaviz[1]Tanggal lahir 15 Juni 1995 (umur 28)[1]Tempat lahir Ahome, Sinaloa, Meksiko[2][3][4]Tinggi 178 cm (5 ft 10 in)[1]Posisi bermain GelandangInformasi klubKlub saat ini PSVNomor 15Karier...

 

 

Disambiguazione – Se stai cercando altri significati, vedi Mozambico (disambigua). Questa voce o sezione sull'argomento Mozambico non cita le fonti necessarie o quelle presenti sono insufficienti. Commento: diverse sezioni e affermazioni senza fonti Puoi migliorare questa voce aggiungendo citazioni da fonti attendibili secondo le linee guida sull'uso delle fonti. Mozambico (dettagli) (dettagli) Mozambico - Localizzazione Dati amministrativiNome completoRepubblica del Mozambico Nome uf...

 

 

Straßlach-Dingharting. Straßlach-Dingharting adalah kota yang terletak di distrik München di Bayern, Jerman. Kota Straßlach-Dingharting memiliki luas sebesar 28.34 km². Straßlach-Dingharting pada tahun 2006, memiliki penduduk sebanyak 2.858 jiwa. lbsKota dan kotamadya di distrik München Aschheim Aying Baierbrunn Brunnthal Feldkirchen Garching bei München Gräfelfing Grasbrunn Grünwald Haar Hohenbrunn Höhenkirchen-Siegertsbrunn Ismaning Kirchheim bei München Neubiberg Neuried O...

The Grove (2005) near Templeton The Grove is a Grade II listed building of historical significance located south of Narberth, Pembrokeshire.[1] It was built by Daniel Poyer in about 1680 shortly after he inherited the property from his father. The house remained in the Poyer family for the next two centuries. Today The Grove is a hotel and restaurant. It caters for special events particularly weddings.[2] The Poyer family The site was occupied by a family of tanners, the Poyer...

 

 

Taxi 2SutradaraGérard KrawczykProduserLuc BessonMichele PetinLaurent PetinDitulis olehLuc BessonPemeranSamy NaceriFrédéric DiefenthalMarion CotillardEmma SjobergBernard FarcyPenata musikAl KhemyaSinematograferThierry GuilmaroDistributorLions Gate FilmsTanggal rilis29 Maret 2000 (Prancis)Durasi88 menitBahasaPrancisAnggaranFRF 70,000,000PrekuelTaxiSekuelTaxi 3IMDbInformasi di IMDb Taxi 2 merupakan sebuah film asal Prancis yang dirilis pada tahun 2000. Film yang disutradarai oleh Gérar...

 

 

American basketball player and coach (1926–2013) Bill SharmanSharman with USC, c. 1950Personal informationBorn(1926-05-25)May 25, 1926Abilene, Texas, U.S.DiedOctober 25, 2013(2013-10-25) (aged 87)Redondo Beach, California, U.S.Listed height6 ft 2 in (1.88 m)Listed weight175 lb (79 kg)Career informationHigh schoolPorterville (Porterville, California)CollegeUSC (1946–1950)NBA draft1950: 2nd round, 17th overall pickSelected by the Washington CapitolsPlayin...

artikel ini perlu dirapikan agar memenuhi standar Wikipedia. Tidak ada alasan yang diberikan. Silakan kembangkan artikel ini semampu Anda. Merapikan artikel dapat dilakukan dengan wikifikasi atau membagi artikel ke paragraf-paragraf. Jika sudah dirapikan, silakan hapus templat ini. (Pelajari cara dan kapan saatnya untuk menghapus pesan templat ini) Universitas Negeri ManadoNama sebelumnyaIKIP (Institut Keguruan dan Ilmu Pendidikan) Negeri ManadoJenisPerguruan Tinggi Negeri - Badan Layanan Umu...

 

 

Cet article est une ébauche concernant une élection en France et l’Ille-et-Vilaine. Vous pouvez partager vos connaissances en l’améliorant (comment ?) selon les recommandations des projets correspondants. 1994 2001 Élections cantonales de 1998 en Ille-et-Vilaine 27 des 53 cantons d'Ille-et-Vilaine les 15 et 22 mars 1998 Type d’élection Élections cantonales Corps électoral et résultats Inscrits 289 517 Votants au 1er tour 168 871   58,33 % Votes e...

 

 

Stasiun Sukagawa須賀川駅Stasiun Sukagawa pada September 2012Lokasi63-1 Nakayama, Sukagawa-shi, Fukushima-ken 962-0004JepangKoordinat37°18′01″N 140°22′21″E / 37.3002°N 140.3724°E / 37.3002; 140.3724Koordinat: 37°18′01″N 140°22′21″E / 37.3002°N 140.3724°E / 37.3002; 140.3724Operator JR EastJalur■ Jalur Utama TōhokuLetak215.1 km dari TokyoJumlah peron2 peron sampingLayananPemberhentian busInformasi lainStatusMemiliki ...

Welcome to my talk page! Here you can tell me what a horrible job I'm doing, if you don't want to just do it on my edits or those talk pages. I'm a new contributor/editor, so I'm open to any constructive advice. :) RM2KX (talk) 00:48, 29 January 2017 (UTC)[reply] RM2KX, you are invited to the Teahouse! Hi RM2KX! Thanks for contributing to Wikipedia. Be our guest at the Teahouse! The Teahouse is a friendly space where new editors can ask questions about contributing to Wikipedia and get help ...

 

 

Questa voce sull'argomento stagioni delle società calcistiche italiane è solo un abbozzo. Contribuisci a migliorarla secondo le convenzioni di Wikipedia. Segui i suggerimenti del progetto di riferimento. Voce principale: Associazione Calcio Crema 1908. Associazione Calcio CremaStagione 1945-1946Sport calcio Squadra Crema Allenatore Guido Dossena Presidente ??? Serie B-C6º posto nel girone B. 1942-1943 1946-1947 Si invita a seguire il modello di voce Questa voce raccoglie le...

 

 

Markis KidoInformasi pribadiNama lahirMarkis KidoKebangsaanIndonesiaLahir(1984-08-11)11 Agustus 1984JakartaMeninggal14 Juni 2021(2021-06-14) (umur 36)Tangerang, BantenTinggi168 cm (5 ft 6 in)Berat90 kg (198 pon) (200 pon)PeganganKananGanda Putra & Ganda CampuranPeringkat tertinggi1 (Hendra Setiawan (27 September 2007[1]) Rekam medali Bulu tangkis putra Mewakili  Indonesia Olimpiade Musim Panas Beijing 2008 Ganda putra Kejuaraan Dunia Kuala L...

Indonesian traditional herbs or spices drink Not to be confused with Jammu, a region in South Asia. For other uses, see Jamu (disambiguation). JamuDifferent types of jamu held in bottles, Solo, Central JavaTypeTraditional MedicineMaterialSpices, CurcumaPlace of originIndonesia This article is part of a series onAlternative medicine General information Alternative medicine History Terminology Alternative veterinary medicine Quackery (health fraud) Rise of modern medicine Pseudoscience Antiscie...

 

 

Edict or proclamation usually issued by a head of state For papal decrees, see Decree (Catholic canon law). The article's lead section may need to be rewritten. Please help improve the lead and read the lead layout guide. (December 2023) (Learn how and when to remove this message) Royal Polish Decree issued by Casimir III the Great A decree is a legal proclamation, usually issued by a head of state such as the president of a republic, or a monarch (a royal decree), according to certain proced...

 

 

Азиатский барсук Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеНадкласс:ЧетвероногиеКлада:АмниотыКлада:СинапсидыКласс:Мле�...

Neobatrachia Обыкновенная квакша Научная классификация Домен:ЭукариотыЦарство:ЖивотныеПодцарство:ЭуметазоиБез ранга:Двусторонне-симметричныеБез ранга:ВторичноротыеТип:ХордовыеПодтип:ПозвоночныеИнфратип:ЧелюстноротыеНадкласс:ЧетвероногиеКласс:ЗемноводныеПодкласс:Б�...

 

 

City in Illinois, United StatesWoodstockCityThe landmark Woodstock Opera House building in historic downtown Woodstock FlagSealLogoMotto(s): True to Its Past; Confident of Its FutureLocation of Woodstock in McHenry County, Illinois.WoodstockShow map of IllinoisWoodstockShow map of the United StatesCoordinates: 42°18′53″N 88°26′51″W / 42.31472°N 88.44750°W / 42.31472; -88.44750CountryUnited States StateIllinois CountyMcHenryTownshipsDorr, Greenwood, Ha...

 

 

River in Texas, United States For the river in California, see San Jacinto River (California). Map of the San Jacinto River and associated watershed Old San Jacinto River Truss Bridge -- Humble, Texas The San Jacinto River (/ˌsæn dʒəˈsɪntoʊ/ SAN jə-SIN-toh, Spanish pronunciation: [ˈri.o ˈsaŋ xaˈsinto]) flows through southeast Texas. It is named after Saint Hyacinth. In the past, it was home to the Karankawa[citation needed] and Akokisa tribes. The river begins with...

Voce principale: Eccellenza 1997-1998. Eccellenza Trentino-Alto Adige(DE) Oberliga Trentino-Südtirol1997-98 Competizione Eccellenza Trentino-Alto Adige Sport Calcio Edizione 7ª Organizzatore FIGC - LNDComitato Regionale Trentino-Alto Adige Luogo  Italia Cronologia della competizione 1996-1997 1998-1999 Manuale Il campionato di Eccellenza Trentino-Alto Adige 1997-1998 è stato il settimo organizzato in Italia. Rappresenta il sesto livello del calcio italiano. Questo è il campionato re...

 

 

Questa voce sull'argomento società di pallacanestro tedesche è solo un abbozzo. Contribuisci a migliorarla secondo le convenzioni di Wikipedia. U.S.C. HeidelbergPallacanestro Segni distintiviUniformi di gara Casa Trasferta Colori sociali Bianco, nero e arancione Dati societariCittàHeidelberg Nazione Germania ConfederazioneFIBA Europe FederazioneDBB CampionatoBasketball-Bundesliga Fondazione1899 DenominazioneU.S.C. Heidelberg(1899-presente) Allenatore Ingo Freyer ImpiantoSNP Dome...