Wardian docs

Number lab

Try it

The app runs here in your browser. Nothing you type leaves it. Open it on its own.

Download number-lab.wardian Import it in Wardian: Settings → Import.

A Wardian module app: 20 exact whole-number functions on 64-bit integers. There is no page. Wardian draws a card for each function, with an input per parameter and a Run button.

Why a module: every function takes whole numbers and returns one. Wardian can show that without help. And because every parameter and result is an i64, JavaScript gets a BigInt back. So fibonacci(92) shows 7540113804746346429 to the last digit, where an ordinary JavaScript number would round it after the 16th.

FileWhat it is
src/lib.rsThe functions. Each #[no_mangle] pub extern "C" fn becomes a card in Wardian. Unit tests at the end.
app.wasmThe module Wardian runs. Built from src/lib.rs.
app.jsonThe title and the description in the app list.
build.shRebuilds app.wasm.
GroupFunctions
Primesis_prime, next_prime, prev_prime, nth_prime, prime_count
Factorssmallest_factor, largest_factor, divisor_count, euler_phi, gcd(a, b), lcm(a, b)
Modularmod_pow(base, exp, m)
Sequencesfibonacci, factorial, binomial(n, k), collatz_steps, collatz_peak
Digitsdigit_sum, reverse_digits, isqrt

How data moves: you type numbers in a card and press Run. Wardian first calls the function with plain JavaScript numbers. The call fails, because the parameters are 64-bit, so Wardian calls it again with BigInts. The module does the work and returns an i64, which arrives as a BigInt. Inside, products use u128, so mod_pow and the prime test never overflow.

How it stays fast on big numbers:

Limits:

Change it: edit src/lib.rs, run cargo test, run ./build.sh, then wardian check ..

This page is apps/number-lab/README.md in the repository. Something wrong or missing? Change that file.