{"id":17717295,"url":"https://github.com/bwesterb/powercycle","last_synced_at":"2025-08-20T23:06:42.133Z","repository":{"id":137660790,"uuid":"111690007","full_name":"bwesterb/powercycle","owner":"bwesterb","description":"Generates a not-so-pseudorandom cyclic permutation using modular exponentiation","archived":false,"fork":false,"pushed_at":"2023-01-29T09:16:34.000Z","size":7,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-06-19T10:05:46.491Z","etag":null,"topics":["cycle","golang","modular-exponentiation","permutation","pseudocode"],"latest_commit_sha":null,"homepage":null,"language":"Go","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/bwesterb.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":"2017-11-22T13:49:32.000Z","updated_at":"2024-03-29T04:22:52.000Z","dependencies_parsed_at":"2024-06-19T09:52:59.112Z","dependency_job_id":"72e1b6e5-1151-4c3a-ba75-2a404cd04853","html_url":"https://github.com/bwesterb/powercycle","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/bwesterb/powercycle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwesterb%2Fpowercycle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwesterb%2Fpowercycle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwesterb%2Fpowercycle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwesterb%2Fpowercycle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bwesterb","download_url":"https://codeload.github.com/bwesterb/powercycle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bwesterb%2Fpowercycle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271400259,"owners_count":24752830,"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-20T02:00:09.606Z","response_time":69,"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":["cycle","golang","modular-exponentiation","permutation","pseudocode"],"created_at":"2024-10-25T14:19:44.170Z","updated_at":"2025-08-20T23:06:42.104Z","avatar_url":"https://github.com/bwesterb.png","language":"Go","readme":"powercycle\n==========\n\nGo package to generate a (not-so\\*) pseudo-random cycle.\n\nExample\n-------\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/bwesterb/powercycle\"\n)\n\nfunc main() {\n\tvar x uint64\n\tcycle := powercycle.New(10)\n\tfor i := 0; i \u003c 10; i++ {\n\t\tfmt.Println(x)\n\t\tx = cycle.Apply(x)\n\t}\n}\n```\n\nmight output\n\n```\n0\n6\n4\n1\n2\n9\n3\n5\n8\n7\n```\n\nNot-so pseudorandom\n-------------------\n\nFor efficiency, the cycles generated are of a very particular form.  So do\nnot use this package if you want to have a real pseudo-random cycle.\n\nHow it works\n------------\nTo generate a cycle of size n, we find a prime p \u003e n + 1 such that\nfurthermore (p - 1)/2 is also a prime.  This makes it easy to find a\ngenerator g modulo p.  The action of the cycle is usually given by\n\n    x ---\u003e (((x + 1) * g) % p) - 1\n\nAs often p \u003e n + 1, this might yield a number bigger than n.\nIn that case the action is repeated.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwesterb%2Fpowercycle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbwesterb%2Fpowercycle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbwesterb%2Fpowercycle/lists"}