{"id":26398614,"url":"https://github.com/h5law/primality","last_synced_at":"2025-08-11T17:32:30.387Z","repository":{"id":240270960,"uuid":"801833783","full_name":"h5law/primality","owner":"h5law","description":"A Go library for checking whether an integer is prime or not, using either the AKS or Miller-Rabin algorithms.","archived":false,"fork":false,"pushed_at":"2024-05-22T11:37:30.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T12:41:56.274Z","etag":null,"topics":["aks","go","golang","miller-rabin","number-theory","primality-test","prime-numbers"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/h5law/primality","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/h5law.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-05-17T02:14:27.000Z","updated_at":"2024-07-14T05:10:52.000Z","dependencies_parsed_at":"2024-05-22T05:24:37.971Z","dependency_job_id":"c2160c2b-1ad9-4fe9-aad7-e41bb774fc09","html_url":"https://github.com/h5law/primality","commit_stats":null,"previous_names":["h5law/primality"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/h5law/primality","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h5law%2Fprimality","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h5law%2Fprimality/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h5law%2Fprimality/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h5law%2Fprimality/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/h5law","download_url":"https://codeload.github.com/h5law/primality/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/h5law%2Fprimality/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269928189,"owners_count":24498383,"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","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aks","go","golang","miller-rabin","number-theory","primality-test","prime-numbers"],"created_at":"2025-03-17T12:31:57.354Z","updated_at":"2025-08-11T17:32:30.266Z","avatar_url":"https://github.com/h5law.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# primality\n\nPrimality is a Golang library for determining whether any given integer\n$i\\in\\mathbb{Z}^+,~i\\ge1$. The library provides two implementations of algorithms\nfor determining the primality of an arbitrarily sized integer, using the `math/big`\nlibrary.\n\nThe two methods provided are the Miller-Rabin and AKS primality test the former\nbeing probabilistic and the latter deterministic, meaning that the Miller-Rabin\nprimality test doesn't guarantee 100% accuracy in certain situations. Whereas\nthe AKS primality test is always 100% accurate - but a lot slower on larger\nintegers.\n\n## Features\n\n### Miller-Rabin:\n\n- Highly accurate probabilistic primality test\n  - 25 rounds and force usage of base 2 recommended for near 100% accuracy\n- Arbitrarily large integer support (`big.Int`)\n- $\\mathcal{O}(r\\cdot s)$ time complexity (assuming `big.Int` operations are\n  $\\mathcal{O}(1)$ where $r$ is the number of repetitions and $s$ the number of\n  trailing zeros on $n$, the number being tested - otherwise it is related to\n  the operations of `big.Int` integers and $n$ itself.\n  - As a prime must be odd $s\\le7$ meaning the time complexity in its worst case\n    is $\\mathcal{O}(175)=\\mathcal{O}(1)$ with 25 repetitions.\n\n### AKS\n\n- Deterministic primality test\n  - Slow overall - but guarantees 100% a valid outcome\n- `int` support only\n\n## TODOs\n\n- Improve speed of the AKS method\n  - Specifically step 5 but overall it is slow\n- Make the AKS method work on arbitrarily sized integers\n  - use `big.Int`s over `int`s\n- Determine the true time and space complexities for both methods\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh5law%2Fprimality","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fh5law%2Fprimality","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh5law%2Fprimality/lists"}