Skip to content

Prime

prime

CLI for calculation of n-th prime number

app = typer.Typer() module-attribute

main(n: Annotated[int, typer.Argument(..., min=1, help='Positive integer')])

Calculate n-th prime number.

Source code in src/python_cli_app_template/cli/prime.py
@app.command()
def main(n: Annotated[int, typer.Argument(..., min=1, help='Positive integer')]):
    """Calculate n-th prime number."""
    typer.echo(f'The {n}-th prime number is {sympy.prime(n)}')