Skip to main content
Home

Built and signed on GitHub Actions

A tiny package for simple math utils

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
a year ago (0.1.5)

tiny-math

A tiny, easy-to-use, zero-dependency package providing some math utils.

Usage

This package is available on jsr.io and compatible with any browsers and JavaScript runtimes.

To install:

# Deno
deno add @babia/tiny-math

# npm
npx jsr add @babia/tiny-math

# yarn
yarn dlx jsr add @babia/tiny-math

# pnpm
pnpm dlx jsr add @babia/tiny-math

# Bun
bunx jsr add @babia/tiny-math

For Deno user, this package is also available on deno.land/x

import * as math from "https://deno.land/x/tiny_math@$VERSION/mod.ts";

Remember to use imports with pinned version to avoid unintended changes.

Examples

Below are some examples of factorial, gcd and lcm. For more, see examples.

factorial

import { factorial } from "@babia/tiny-math";

console.log(factorial(0));     // 0! = 1
console.log(factorial(7));     // 7! = 5040
console.log(factorial(15));    // 15! = 1307674368000
console.log(factorial(20));    // 20! = 2432902008176640000

gcd and lcm

import { gcd, lcm } from "@babia/tiny-math";

console.log(gcd(27, 60));       // 3
console.log(gcd(24, 32, 21));   // 1
console.log(lcm(50, 90));       // 450
console.log(lcm(55, 30, 23));   // 7590

Documentation

Please go to this page and navigate to any function you want to see.

License

This package is under MIT License.

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@babia/tiny-math

Import symbol

import * as tiny_math from "@babia/tiny-math";
or

Import directly with a jsr specifier

import * as tiny_math from "jsr:@babia/tiny-math";

Add Package

pnpm i jsr:@babia/tiny-math
or (using pnpm 10.8 or older)
pnpm dlx jsr add @babia/tiny-math

Import symbol

import * as tiny_math from "@babia/tiny-math";

Add Package

yarn add jsr:@babia/tiny-math
or (using Yarn 4.8 or older)
yarn dlx jsr add @babia/tiny-math

Import symbol

import * as tiny_math from "@babia/tiny-math";

Add Package

npx jsr add @babia/tiny-math

Import symbol

import * as tiny_math from "@babia/tiny-math";

Add Package

bunx jsr add @babia/tiny-math

Import symbol

import * as tiny_math from "@babia/tiny-math";