{"id":20187444,"url":"https://github.com/michaelb/simple_prime_generator","last_synced_at":"2026-05-13T09:05:41.797Z","repository":{"id":104285949,"uuid":"313689302","full_name":"michaelb/simple_prime_generator","owner":"michaelb","description":"A quick evening take on prime generation","archived":false,"fork":false,"pushed_at":"2020-11-24T10:54:03.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T04:38:41.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-17T17:11:59.000Z","updated_at":"2020-11-24T10:54:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"92d9f72b-4488-441b-ae35-24ab7e56da84","html_url":"https://github.com/michaelb/simple_prime_generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelb%2Fsimple_prime_generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelb%2Fsimple_prime_generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelb%2Fsimple_prime_generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelb%2Fsimple_prime_generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelb","download_url":"https://codeload.github.com/michaelb/simple_prime_generator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241622614,"owners_count":19992504,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T03:23:57.515Z","updated_at":"2025-11-28T10:03:06.712Z","avatar_url":"https://github.com/michaelb.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"a simple take on generating primes in a efficient (or not) way. It also illustrates time vs space(memory) complexity.\n\nprime.c is a simple, slow, but robust implementation that should be able to go up to 2^64-1 (while not in a reasonable time)\n\nprime_sundaram3.c is a very, very fast sieve but it needs O(n) memory (to calculate primes up to n-1). While memory compression could be achieved, this would be at the expense of performance.\n\n## How to run:\n\n- compile with your favorite (or not) compiler : `gcc prime.c`\n- run the executable: `./a.out`\n\n## How to use within your project (don't)\n\nI'd suggest writing your own, but in case you don't want to, the code in the prime\\_\\*.c files should be clear enough to reuse: there is a section within the loops where the primes values are exposed.\n\nThough, whether the program can output in real time the primes you need or if it needs time to calculate then output all at once depends on the implementation but also the method and may not be modifiable.\n\n## Speed results\n\n(on i5 4210u@1.7GHz, 8Go DDR3)\n\n- prime.c: counted primes up to 1e6 in 40s\n- prime_sundaram3.c: counted primes up to 1e9 in 1m02s, though it had to use a whopping 4Go of RAM to do so.\n\nBoth program are single threaded, and pale in comparison to state-of-the-art prime generators such as [primesieve](https://github.com/kimwalisch/primesieve) which achieve counting primes up to 1e9 in 0.180s, and use way less memory\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelb%2Fsimple_prime_generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelb%2Fsimple_prime_generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelb%2Fsimple_prime_generator/lists"}