Algoritmi za generiranje prostih brojeva manjih od N

Abstract

U radu je obrađeno generiranje prostih brojeva manjih od N korištenjm tri algoritma: Eratostenovog, Sundaramovog i Atkinovog sita. U prvom poglavlju navedena je definicija prostih brojeva, te obrađena njihova važnost. Obrađene su kvadratne forme radi boljeg razumijevanja rada Atkinovog sita. U drugom poglavlju navedena je definicija niza prostih brojeva, te su iskazani teoremi koji dokazuju tvrdnje o asimptotskoj gustoći prostih brojeva u skupu prirodnih brojeva. Opisani su algoritmi sita, te je određena asimptotska vremenska složenost za svaki od njih. U trećem poglavlju izvršena je implementacija u programskom jeziku Python i izmjereno vrijeme izvršenja na računalu. Izvršena je optimizacija Eratostenovog algoritma, te je ponovo određena asimptotska vremenska složenost svake pojedine optimizacije. Na kraju je izvršeno usporedno mjerenje vremena izvršenja na računalu, iz čega je donesen zaključak. Iz dobivenih rezultata vidimo da se najbrže na računalu izvršava Eratostenovo sito, a od njegovih optimizacija Faktorizacija kotačem 235. Iako Sundaramovo i Atkinovo sito imaju manju asimptotsku vremensku složenost u odnosu na Eratostenovo, samo izvršavanje u programskom jeziku Python je dulje zbog izračunavanja kvadratnih formi.This Master’s degree thesis deals with generating prime numbers smaller than N. It deals with three algorithms, Eratosten’s sieve, Sundaram’s sieve, and Atkin’s sieve. The thesis is composed of three chapters. Chapter One is introductory and defines basic terminology used in the thesis. The chapter is subdivided into three parts. First Part gives the definition of prime numbers. Second Part tells about importance of prime numbers and finally Third Part explains quadratic forms. Quadratic forms were explained for better understanding of Atkin’s sieve. Chapter Two deals with prime number series and algorithms for generating them. Chapter consists of three parts. Part One gives a definition of a series of prime numbers, and theorems that demonstrate asymptotic density of prime numbers in a set of natural numbers. Part two describes sieving algorithms and in Part Three asymptotic time complexity is determined for each one of them. Chapter Three gives implementation of the algorithms in programming language Python and determines the time taken to execute them on the computer. Part Two of the Third Chapter describes optimizations of the Eratosten’s algorithm. In Part Three the asymptotic time complexity of each optimization is determined. In Part Four we draw conclusions from tables of execution times on the computer. From the results obtained we see that the Eratosten’s sieve has the fastest execution time on a PC and that Factorization Wheel 235 is the fastest optimization. Although Sundaram’s and Atkin’s site have better asymptotic time complexity than Eratosten’s, because of the implementations in programming language Python their execution time is longer due to quadratic form calculations

    Similar works