{"id":21831372,"url":"https://github.com/nodef/extra-math","last_synced_at":"2026-02-26T07:48:21.108Z","repository":{"id":40000275,"uuid":"141781770","full_name":"nodef/extra-math","owner":"nodef","description":"Mathematics is the classification and study of all possible patterns.","archived":false,"fork":false,"pushed_at":"2025-04-08T17:12:02.000Z","size":767,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T05:38:25.197Z","etag":null,"topics":["aliquot-sum","arithmetic-mean","binomial","ceil","ceil-div","constrain","cubic-mean","degrees","distance","extra","factorial","floor","floor-div","gcd","geometric-mean","harmonic-mean","is-pow","is-prime","lcm","math"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/extra-math","language":"JavaScript","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/nodef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2018-07-21T04:43:25.000Z","updated_at":"2025-04-08T17:12:02.000Z","dependencies_parsed_at":"2024-11-06T21:40:26.410Z","dependency_job_id":"5edfb9f8-f00e-4c35-9e08-ae6201796c91","html_url":"https://github.com/nodef/extra-math","commit_stats":{"total_commits":109,"total_committers":1,"mean_commits":109.0,"dds":0.0,"last_synced_commit":"54bc807b158ae9c1cb439f8677c9d5d160434509"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-math","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-math/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-math/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodef%2Fextra-math/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodef","download_url":"https://codeload.github.com/nodef/extra-math/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670506,"owners_count":21142897,"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":["aliquot-sum","arithmetic-mean","binomial","ceil","ceil-div","constrain","cubic-mean","degrees","distance","extra","factorial","floor","floor-div","gcd","geometric-mean","harmonic-mean","is-pow","is-prime","lcm","math"],"created_at":"2024-11-27T19:10:02.672Z","updated_at":"2026-02-26T07:48:16.069Z","avatar_url":"https://github.com/nodef.png","language":"JavaScript","readme":"**Mathematics** is the classification and study of all possible patterns [(1)].\u003cbr\u003e\n📦 [Node.js](https://www.npmjs.com/package/extra-math),\n🌐 [Web](https://www.npmjs.com/package/extra-math.web),\n📜 [Files](https://unpkg.com/extra-math/),\n📰 [JSDoc](https://nodef.github.io/extra-math/),\n📘 [Wiki](https://github.com/nodef/extra-math/wiki/).\n\nThis package includes common number functions related to querying *about*\nnumbers, *comparing* numbers, *rounding* numbers, performing *rounded division*,\nperforming *modulo* operations, *controlling range* of numbers, performing\n*arithmetic* operations, obtaining *divisors* of a number (and related\noperations), getting the number of possible *arrangements* of a set of objects,\nperforming *geometry*-related calculations, performing basic *statistical*\nanalysis, and finding various *statistical means*.\n\n**Natural numbers**: There are 3 different ways of performing the *modulo*\noperation: [rem], [mod], and [modp]. [gcd]/`HCF` and [lcm] of a list of numbers\ncan be obtained. To calculate the number of ways of *ordering items*, use\n[factorial]/`P(n, k)`, [binomial]/`C(n, k)`, or [multinomial]/`n!/k₁!k₂!...`.\n\n**Real numbers**: *Range* of a number can be controlled with [constrain],\n[normalize], or [remap]. Use [lerp] for *linear interpolation* (or extrapolation);\n[root] for calculating the *n-th root* of a number; and [log] to find the\n*logarithm* of a number with a given base.\n\n**Geometry**: Perform conversion from [degrees] to [radians] and vice versa.\nFind the [magnitude] of a vector or [distance] between two points.\n\n**Statistics**: For a list of numbers, we can calculate the [sum], [product],\n[arithmeticMean]. [median] gives the value lying in the middle when the numbers are\nsorted, and [modes] gives the values which are repeated most often. The\ndifference between the largest and the smallest values is the [range].\n[variance] is a measure of variability of numbers.\n\nThis package is available in *Node.js* and *Web* formats. To use it on the web,\nsimply use the `extra_math` global variable after loading with a `\u003cscript\u003e`\ntag from the [jsDelivr CDN].\n\n[(1)]: https://en.wikipedia.org/wiki/Walter_Warwick_Sawyer\n[jsDelivr CDN]: https://cdn.jsdelivr.net/npm/extra-math.web/index.js\n\n\u003e Stability: [Experimental](https://www.youtube.com/watch?v=L1j93RnIxEo).\n\n\u003cbr\u003e\n\n\n```javascript\nconst xmath = require('extra-math');\n// import * as xmath from \"extra-math\";\n// import * as xmath from \"https://unpkg.com/extra-math/index.mjs\"; (deno)\n\nxmath.sum(1, 2, 3, 4);\n// → 10\n\nxmath.median(1, 7, 8);\n// → 7\n\nxmath.variance(1, 2, 3, 4);\n// → 1.25\n\nxmath.lcm(2, 3, 4);\n// → 12\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n## Index\n\n| Property | Description |\n|  ----  |  ----  |\n| [floor] | Round down a number to specific precision. |\n| [ceil] | Round up a number to specific precision. |\n| [round] | Round a number to specific precision. |\n|  |  |\n| [floorDiv] | Perform floor-divison of two numbers. |\n| [ceilDiv] | Perform ceiling-divison of two numbers. |\n| [roundDiv] | Perform rounded-divison of two numbers. |\n|  |  |\n| [rem] | Find the remainder of x/y with sign of x (truncated division). |\n| [mod] | Find the remainder of x/y with sign of y (floored division). |\n| [modp] | Find the remainder of x/y with +ve sign (euclidean division). |\n|  |  |\n| [constrain] | Constrain a number within a minimum and a maximum value. |\n| [normalize] | Normalize a number from its current range into a value between 0 and 1. |\n| [remap] | Re-map a number from one range to another. |\n| [lerp] | Linearly interpolate a number between two numbers. |\n|  |  |\n| [isPow] | Check if a number is a power-of-n. |\n| [prevPow] | Find largest power-of-n less than or equal to given number. |\n| [nextPow] | Find smallest power-of-n greater than or equal to given number. |\n|  |  |\n| [root] | Find the nth root of a number (ⁿ√). |\n| [log] | Find the logarithm of a number with a given base. |\n|  |  |\n| [properDivisors] | List all divisors of a number, except itself. |\n| [aliquotSum] | Sum all proper divisors of a number. |\n| [minPrimeFactor] | Find the least prime number which divides a number. |\n| [maxPrimeFactor] | Find the greatest prime number which divides a number. |\n| [primeFactors] | Find the prime factors of a number. |\n| [primeExponentials] | Find the prime factors and respective exponents of a number. |\n| [isPrime] | Check if number is prime. |\n| [gcd] | Find the greatest common divisor of numbers. |\n| [lcm] | Find the least common multiple of numbers. |\n|  |  |\n| [factorial] | Find the factorial of a number. |\n| [binomial] | Find the number of ways to choose k elements from a set of n elements. |\n| [multinomial] | Find the number of ways to put n objects in m bins (n=sum(kᵢ)). |\n|  |  |\n| [degrees] | Convert radians to degrees. |\n| [radians] | Convert degrees to radians. |\n| [magnitude] | Calculate the magnitude (length) of a vector. |\n| [distance] | Calculate the distance between two points. |\n|  |  |\n| [sum] | Find the sum of numbers (Σ). |\n| [product] | Find the product of numbers (∏). |\n| [median] | Find the value separating the higher and lower halves of numbers. |\n| [modes] | Find the values that appear most often. |\n| [range] | Find the smallest and largest values. |\n| [variance] | Find the mean of squared deviation of numbers from its mean. |\n|  |  |\n| [arithmeticMean] | Find the average of numbers. |\n| [geometricMean] | Find the geometric mean of numbers. |\n| [harmonicMean] | Find the harmonic mean of numbers. |\n| [quadriaticMean] | Find the quadriatic mean of numbers. |\n| [cubicMean] | Find the cubic mean of numbers. |\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n## References\n\n- [Yang, Z. H., \u0026 Tian, J. F. (2018). An accurate approximation formula for gamma function. Journal of inequalities and applications, 2018(1), 56.](https://doi.org/10.1186/s13660-018-1646-6)\n- [MathLib by @alawatthe](https://github.com/alawatthe/MathLib)\n- [Processing Reference](https://processing.org/reference)\n- [Common mathematical functions by cppreference](https://en.cppreference.com/w/cpp/numeric/math)\n- [Modulo operation](https://en.wikipedia.org/wiki/Modulo_operation)\n- [Euclidean algorithm](https://en.wikipedia.org/wiki/Euclidean_algorithm)\n- [Least common multiple](https://en.wikipedia.org/wiki/Least_common_multiple)\n- [Permutation](https://en.wikipedia.org/wiki/Permutation)\n- [Binomial coefficient](https://en.wikipedia.org/wiki/Binomial_coefficient)\n- [Multinomial distribution](https://en.wikipedia.org/wiki/Multinomial_distribution)\n- [Conventional commits](https://www.conventionalcommits.org/en/v1.0.0-beta.2/)\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n\n[![](https://img.youtube.com/vi/dW8Cy6WrO94/maxresdefault.jpg)](https://www.youtube.com/watch?v=dW8Cy6WrO94)\u003cbr\u003e\n[![ORG](https://img.shields.io/badge/org-nodef-green?logo=Org)](https://nodef.github.io)\n[![DOI](https://zenodo.org/badge/141781770.svg)](https://zenodo.org/badge/latestdoi/141781770)\n[![Coverage Status](https://coveralls.io/repos/github/nodef/extra-math/badge.svg?branch=master)](https://coveralls.io/github/nodef/extra-math?branch=master)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/13d7102b0273f2a77c66/test_coverage)](https://codeclimate.com/github/nodef/extra-math/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/13d7102b0273f2a77c66/maintainability)](https://codeclimate.com/github/nodef/extra-math/maintainability)\n![](https://ga-beacon.deno.dev/G-RC63DPBH3P:SH3Eq-NoQ9mwgYeHWxu7cw/github.com/nodef/extra-math)\n\n[floor]: https://github.com/nodef/extra-math/wiki/floor\n[ceil]: https://github.com/nodef/extra-math/wiki/ceil\n[round]: https://github.com/nodef/extra-math/wiki/round\n[floorDiv]: https://github.com/nodef/extra-math/wiki/floorDiv\n[ceilDiv]: https://github.com/nodef/extra-math/wiki/ceilDiv\n[roundDiv]: https://github.com/nodef/extra-math/wiki/roundDiv\n[rem]: https://github.com/nodef/extra-math/wiki/rem\n[mod]: https://github.com/nodef/extra-math/wiki/mod\n[modp]: https://github.com/nodef/extra-math/wiki/modp\n[constrain]: https://github.com/nodef/extra-math/wiki/constrain\n[normalize]: https://github.com/nodef/extra-math/wiki/normalize\n[remap]: https://github.com/nodef/extra-math/wiki/remap\n[lerp]: https://github.com/nodef/extra-math/wiki/lerp\n[isPow]: https://github.com/nodef/extra-math/wiki/isPow\n[prevPow]: https://github.com/nodef/extra-math/wiki/prevPow\n[nextPow]: https://github.com/nodef/extra-math/wiki/nextPow\n[root]: https://github.com/nodef/extra-math/wiki/root\n[log]: https://github.com/nodef/extra-math/wiki/log\n[properDivisors]: https://github.com/nodef/extra-math/wiki/properDivisors\n[aliquotSum]: https://github.com/nodef/extra-math/wiki/aliquotSum\n[minPrimeFactor]: https://github.com/nodef/extra-math/wiki/minPrimeFactor\n[maxPrimeFactor]: https://github.com/nodef/extra-math/wiki/maxPrimeFactor\n[primeFactors]: https://github.com/nodef/extra-math/wiki/primeFactors\n[primeExponentials]: https://github.com/nodef/extra-math/wiki/primeExponentials\n[isPrime]: https://github.com/nodef/extra-math/wiki/isPrime\n[gcd]: https://github.com/nodef/extra-math/wiki/gcd\n[lcm]: https://github.com/nodef/extra-math/wiki/lcm\n[factorial]: https://github.com/nodef/extra-math/wiki/factorial\n[binomial]: https://github.com/nodef/extra-math/wiki/binomial\n[multinomial]: https://github.com/nodef/extra-math/wiki/multinomial\n[degrees]: https://github.com/nodef/extra-math/wiki/degrees\n[radians]: https://github.com/nodef/extra-math/wiki/radians\n[magnitude]: https://github.com/nodef/extra-math/wiki/magnitude\n[distance]: https://github.com/nodef/extra-math/wiki/distance\n[sum]: https://github.com/nodef/extra-math/wiki/sum\n[product]: https://github.com/nodef/extra-math/wiki/product\n[median]: https://github.com/nodef/extra-math/wiki/median\n[modes]: https://github.com/nodef/extra-math/wiki/modes\n[range]: https://github.com/nodef/extra-math/wiki/range\n[variance]: https://github.com/nodef/extra-math/wiki/variance\n[arithmeticMean]: https://github.com/nodef/extra-math/wiki/arithmeticMean\n[geometricMean]: https://github.com/nodef/extra-math/wiki/geometricMean\n[harmonicMean]: https://github.com/nodef/extra-math/wiki/harmonicMean\n[quadriaticMean]: https://github.com/nodef/extra-math/wiki/quadriaticMean\n[cubicMean]: https://github.com/nodef/extra-math/wiki/cubicMean\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fextra-math","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodef%2Fextra-math","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodef%2Fextra-math/lists"}