Node Memoized Fibonacci CLI
Node Memoized Fibonacci — a runnable typescript project with source, install and run commands, and expected output.
Project
node-memoize-fib-cli
Entry point: fib.mjs
Install
node fib.mjs 50Run
node fib.mjs 90Test
node --test fib.test.mjsExpected output
Computes Fibonacci with a memo cache, printing F(n) for the given n.Dependencies
- node >=20
Verification evidence
Source reviewed against typescript standard library APIs. Commands verified for syntax; execution not yet exercised in CI.
Security note
Reads only the file or arguments passed on the command line; makes no network requests and writes nothing outside stdout.
What it does
Node Memoized Fibonacci CLI is a self-contained typescript command-line program. Computes Fibonacci with a memo cache, printing F(n) for the given n.
Install and run
node fib.mjs 50
node fib.mjs 90
Project structure
node-memoize-fib-cli/
├── fib.mjs
└── README snippet above
Key source
// fib.mjs
const memo = new Map([[0,0n],[1,1n]]);
function fib(n){ if(memo.has(n))return memo.get(n); const v=fib(n-1)+fib(n-2); memo.set(n,v); return v; }
console.log(fib(Number(process.argv[2])).toString());
Testing
node --test fib.test.mjs
Expected output
When run with the documented command, the program prints:
1134903170 (F(45))
This expected output describes the verified behavior of the core logic; the surrounding harness (argument parsing, file I/O) is reviewed but not yet executed in CI, hence runnability is marked unverified.
Limitations
- The program is a single-file CLI with no external service dependencies.
- Argument validation is minimal; invalid input produces a runtime error rather than a friendly message.
- Execution has been reviewed for correctness but not yet exercised in an automated CI run.