返回 Skill 列表
extension
分类: 开发与工程无需 API Key

bignum-calculator

任意精度整数计算器,用于处理非常大的数字。当用户需要计算超出标准数值限制的数字时使用,包括大数的阶乘(例如,100!)、具有大指数的幂运算(例如,2^1000)、数百位数的算术运算,或素数检验、最大公约数、最小公倍数、斐波那契数列以及二项式系数等操作。

person作者: jakexiaohubgithub

Big Number Calculator

Perform arbitrary precision integer arithmetic using Python's native big integer support.

Quick Start

Run the calculator script:

python scripts/bignum_calc.py <operation> <args...>

Supported Operations

| Operation | Args | Example | Description | |-----------|------|---------|-------------| | add | a b | add 999999999999999999 1 | Addition | | sub | a b | sub 1000000000000 1 | Subtraction | | mul | a b | mul 123456789 987654321 | Multiplication | | div | a b | div 1000000000000 7 | Integer division | | mod | a b | mod 1000000000007 1000000007 | Modulo | | pow | base exp | pow 2 1000 | Power (2^1000) | | fact | n | fact 100 | Factorial (100!) | | gcd | a b | gcd 123456789 987654321 | Greatest common divisor | | lcm | a b | lcm 12345 67890 | Least common multiple | | prime | n | prime 104729 | Check if prime | | digits | n | digits 12345678901234567890 | Count digits | | digitsum | n | digitsum 12345678901234567890 | Sum of digits | | fib | n | fib 1000 | n-th Fibonacci number | | binomial | n k | binomial 100 50 | Binomial coefficient C(n,k) |

Examples

# Calculate 2^1000
python scripts/bignum_calc.py pow 2 1000

# Calculate 100!
python scripts/bignum_calc.py fact 100

# Calculate 1000th Fibonacci number
python scripts/bignum_calc.py fib 1000

# Check if a large number is prime
python scripts/bignum_calc.py prime 104729

# Calculate C(100, 50)
python scripts/bignum_calc.py binomial 100 50

Direct Python Usage

For complex calculations, use Python directly:

# Large factorial
import math
result = math.factorial(1000)
print(f"1000! has {len(str(result))} digits")

# Large power
result = 2 ** 10000
print(f"2^10000 has {len(str(result))} digits")

# Modular exponentiation (efficient)
result = pow(2, 1000000, 10**9 + 7)