{"id":34208665,"url":"https://github.com/txaty/lfs","last_synced_at":"2026-03-12T01:35:58.467Z","repository":{"id":64887190,"uuid":"539387301","full_name":"txaty/lfs","owner":"txaty","description":"Blazingly fast Lagrange Four Square Sum Solver.","archived":false,"fork":false,"pushed_at":"2025-02-11T16:26:33.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-19T00:34:18.917Z","etag":null,"topics":["biginteger","blazingly-fast","four-square","four-square-sum","go","golang","lagrange-four-square","lagrange-four-square-sum"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/txaty.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":"2022-09-21T08:38:48.000Z","updated_at":"2025-10-03T03:33:04.000Z","dependencies_parsed_at":"2024-06-20T09:24:19.277Z","dependency_job_id":"e3b47919-e650-4d7c-95f6-cc87720b31cf","html_url":"https://github.com/txaty/lfs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/txaty/lfs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txaty%2Flfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txaty%2Flfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txaty%2Flfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txaty%2Flfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/txaty","download_url":"https://codeload.github.com/txaty/lfs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/txaty%2Flfs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30412088,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T00:40:14.898Z","status":"ssl_error","status_checked_at":"2026-03-12T00:40:08.439Z","response_time":84,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["biginteger","blazingly-fast","four-square","four-square-sum","go","golang","lagrange-four-square","lagrange-four-square-sum"],"created_at":"2025-12-15T20:23:16.155Z","updated_at":"2026-03-12T01:35:58.461Z","avatar_url":"https://github.com/txaty.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LFS - Lagrange Four-Squares\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/txaty/lfs.svg)](https://pkg.go.dev/github.com/txaty/lfs)\n[![Go Report Card](https://goreportcard.com/badge/github.com/txaty/lfs)](https://goreportcard.com/report/github.com/txaty/lfs)\n[![codecov](https://codecov.io/github/txaty/lfs/graph/badge.svg?token=ggYw40inA4)](https://codecov.io/github/txaty/lfs)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/fa8bf34169a242d58a1d952988f2e81e)](https://app.codacy.com/gh/txaty/lfs/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_grade)\n[![MIT license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)\n\nLFS is a Go package that implements an optimized algorithm for solving the Lagrange four-squares problem, even for very large integers.\nIt computes a representation of any positive integer `n` as the sum of four squares:\n\n$$\nn = {w_0}^2 + {w_1}^2 + {w_2}^2 + {w_3}^2\n$$\n\nThis implementation is highly optimized for very large integers (e.g., 1000 bits, 2000 bits, or more).\n\nThe underlying algorithms are based on Section 3 of the paper [Finding the Four Squares in Lagrange's Theorem](https://campus.lakeforest.edu/trevino/finding4squares.pdf) with additional improvements that significantly enhance performance.\n\n## Usage\n\nBelow is a simple example:\n\n```go\npackage main\n\nimport (\n    \"crypto/rand\"\n    \"fmt\"\n    \"log\"\n    \"math/big\"\n\n    \"github.com/txaty/lfs\"\n)\n\nfunc main() { \n    // Create a new solver with default options.\n    solver := lfs.NewSolver()\n\n    // Define a large integer.\n    limit := new(big.Int).Lsh(big.NewInt(1), 1200)\n    n, err := rand.Int(rand.Reader, limit)\n    if err != nil {\n        log.Fatal(err)\n    }\n\n    // Compute the four-square representation.\n    result := solver.Solve(n)\n\n    // Display the result.\n    fmt.Printf(\"Representation of n as sum of four squares: %s\\n\", result)\n\n    // Verify the representation.\n    if lfs.Verify(n, result) {\n        fmt.Println(\"Verification succeeded: The squares sum to n.\")\n    } else {\n        log.Fatal(\"Verification failed: The computed squares do not sum to n.\")\n    }\n}\n```\n\n## Configuration Options\n\nThe solver is configurable via functional options when creating a new instance. For example:\n\n- **WithFCMThreshold**: Sets the threshold above which the advanced FCM algorithm is used.\n  Example:\n    ```go\n    solver := lfs.NewSolver(\n        lfs.WithFCMThreshold(new(big.Int).Lsh(big1, 600)), // Use FCM for numbers ≥ 2^600\n    )\n    ```\n- **WithNumRoutines**: Sets the number of concurrent goroutines for the randomized search.\n  Example:\n    ```go\n    solver := lfs.NewSolver(\n        lfs.WithNumRoutines(8), // Use 8 goroutines for parallel computation\n    )\n    ```\n\n## Dependencies\n\nThis project requires the following dependencies:\n\n- [txaty/go-bigcomplex](https://github.com/txaty/go-bigcomplex): A big complex number library supporting big Gaussian\n  and Hurwitz integers.\n- [lukechampine.com/frand](https://github.com/lukechampine/frand): A fast randomness generation library.\n\n## License\n\nThis project is released under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftxaty%2Flfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftxaty%2Flfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftxaty%2Flfs/lists"}