---
name: math
description: 'Small pure computations -- primality, Fibonacci. Tools: fibonacci, is-prime. Use when a request needs any of these; each tool''s own trigger is in SKILL.md.'
compatibility: 'Requires fragletc and Docker. Hermetic: no network access.'
metadata:
  tags: computation
  tools: fibonacci.py, is-prime.py
---

# Math

Small pure computations -- primality, Fibonacci.

Every tool below is one executable file beside this `SKILL.md`, in the directory the commands below call `<skill-dir>`. Run it directly. Two host requirements: [`fragletc`](https://github.com/ofthemachine/fraglet) (`curl -fsSL https://raw.githubusercontent.com/ofthemachine/fraglet/main/install.sh | sh && fragletc version`) and Docker; the image, parameters, outputs and network reach are declared in the file itself. Before running a tool, print its contract:

```sh
<skill-dir>/fibonacci.py --fraglet-help
```

Parameters are passed as `-p name=value` (a `file` parameter takes a host path); declared outputs are copied out with `--output <name>[=<host path>]`. A missing required parameter fails host-side with exit 2 before any container starts; otherwise the tool's own exit code is the run's. A declared output not named with `--output` is produced and discarded (a stderr note says what you could have copied). Add `--receipt run.json` (or set `FRAGLETC_RECEIPT_DIR`) to record the run: the receipt carries the tool's `procedure_hash`, image digest, parameters, and every input and output by content hash, and `receipt/attest.py` can verify it later without re-running anything.

## Tools

### `fibonacci.py`

The Nth Fibonacci number (0-indexed: F(0)=0, F(1)=1). Pure computation, no network.

Use when the user asks for a Fibonacci number by index.

```sh
<skill-dir>/fibonacci.py -p n="<n>"
```

Parameters:
- `n` (string, required) — 0-indexed position of the Fibonacci number to compute

Outputs:
- stdout

Runs in `ofthemachine/python3@sha256:a015b4f9f0e7c1648f8fcd4164f6a296dd3c9189404f88f333a9764d08d13522`; hermetic — `network=none`; a run is a pure function of its inputs and safe to memoize.

### `is-prime.py`

Check whether a number is prime, and show its smallest prime factor if not. Pure computation, no network.

Use when the user asks whether a number is prime or for its smallest factor.

```sh
<skill-dir>/is-prime.py -p n="<n>"
```

Parameters:
- `n` (string, required) — Integer to test for primality

Outputs:
- stdout

Runs in `ofthemachine/python3@sha256:a015b4f9f0e7c1648f8fcd4164f6a296dd3c9189404f88f333a9764d08d13522`; hermetic — `network=none`; a run is a pure function of its inputs and safe to memoize.
