← Runnable Projects

阅读中文版本

Python Memoized Fibonacci CLI

Python Memoized Fibonacci — a runnable python project with source, install and run commands, and expected output.

intermediatepythonunverified

Project

py-fib-memo-cli

Entry point: fib.py

Install

python fib.py 50

Run

python fib.py 90

Test

pytest fib_test.py

Expected output

Computes Fibonacci with lru_cache decorator and prints F(n).

Dependencies

  • python >=3.10

Verification evidence

Source reviewed against python 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

Python Memoized Fibonacci CLI is a self-contained python command-line program. Computes Fibonacci with lru_cache decorator and prints F(n).

Install and run

python fib.py 50
python fib.py 90

Project structure

py-fib-memo-cli/
├── fib.py
└── README snippet above

Key source

# fib.py
import sys
from functools import lru_cache
@lru_cache(maxsize=None)
def fib(n):
    return n if n < 2 else fib(n-1) + fib(n-2)
print(fib(int(sys.argv[1])))

Testing

pytest fib_test.py

Expected output

When run with the documented command, the program prints:

2880067194370816120   (F(90))

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.