{"id":16777025,"url":"https://github.com/fb55/mathutils","last_synced_at":"2025-06-10T08:34:12.765Z","repository":{"id":4297825,"uuid":"5429037","full_name":"fb55/MathUtils","owner":"fb55","description":"a collection of math-related functions","archived":false,"fork":false,"pushed_at":"2012-10-21T11:47:51.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-17T16:09:55.043Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fb55.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}},"created_at":"2012-08-15T17:18:23.000Z","updated_at":"2014-01-15T01:57:19.000Z","dependencies_parsed_at":"2022-09-17T22:22:38.780Z","dependency_job_id":null,"html_url":"https://github.com/fb55/MathUtils","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/fb55%2FMathUtils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2FMathUtils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2FMathUtils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2FMathUtils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fb55","download_url":"https://codeload.github.com/fb55/MathUtils/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fb55%2FMathUtils/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259038354,"owners_count":22796604,"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-10-13T07:11:39.255Z","updated_at":"2025-06-10T08:34:12.736Z","avatar_url":"https://github.com/fb55.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#MathUtils\n\na collection of math-related functions\n\n    npm install mathutils\n\n###Currently available functions\n\n#####isEven(n) / isOdd(n)\nCheck if the bit for `2^0` is set. If it is, `n must be odd.\n\n#####powermod(a, b, c)\npowermod is a way of computing `(a ^ b) mod c` without having to deal with giant numbers that would loose their precision.\n\n#####slowIsPrime(n)\nReturns if `n` is a prime. Extremely slow, but absolutely accurate.\n\n#####fastIsPrime(n)\nRetuns if a `n` is a prime. Based upon [Fermat's little theorem](http://en.wikipedia.org/wiki/Fermat%27s_little_theorem).\n\nNote: Doesn't take care of carmichael primes, so you probably want to use this in combination with slowIsPrime.\n\n#####isPrime(n)\nRuns both `fastIsPrime` and `slowIsPrime`. This way, it manages to be both (relatively) fast and accurate.\n\n#####randomPrime(length)\nReturns a pseudo-random prime number (based on `Math.random`). `length` defaults to 3.\n\n#####gcd(a, b)\nReturns the greatest common divisor of `a` and `b`. Based on [Euclids algorithm](http://en.wikipedia.org/wiki/Euclid%27s_algorithm)\n\n#####egcd(a, b)\nComputes the [extended Euclidean algorithm](http://en.wikipedia.org/wiki/Extended_Euclidean_algorithm). Returns an array `[d, s, t]`.\n\n    gcd(a, b) = d = s * a + t * b\n\n#####modularInverse(a, b)\nReturns the [modular multiplicative inverse](http://en.wikipedia.org/wiki/Modular_multiplicative_inverse) of `a` and `b`.\n\n###TODO\n* write tests\n* add more documentation\n* learn how to breakdance","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffb55%2Fmathutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffb55%2Fmathutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffb55%2Fmathutils/lists"}