Big Integer Calculator
Big integer calculator with exact BigInt math: add, multiply, power, modular exponentiation, GCD, LCM, factorial, square root and primality test.
Enter any whole number (up to 10,000 digits, optional leading minus). For factorial it is n, for square root and primality it is the only number.
Choose the operation to perform on the big integers
Second operand: the divisor for division and modulo, the exponent for power and modular exponentiation, the modulus for modular inverse, the target base (2 to 36) for base conversion
Results
Result
22222222112222222211
- Result with digit groups
- 22,222,222,112,222,222,211
- Digits in Result
- 20
- Digits in Value 1
- 20
- Digits in Value 2
- 19
- Scientific notation (first 10 digits)
- 2.222222211 × 10^19
- As a plain JavaScript Number
- 22222222112222220000 (rounded: a Number keeps about 16 significant digits)
- Steps
- 12345678901234567890 + 9876543210987654321 = 22222222112222222211
The formula
a + b, a - b, a x b, a / b (with remainder), a^b, a mod b, a^b mod m, gcd(a, b), lcm(a, b), n!, floor(sqrt(n)), base conversion, primality
- a, b
- Operands
- m
- Modulus
- Digit Count
- Result Length
- Remainder
- Division Remainder
Worked example — Value 1 12345678901234567890, Value 2 9876543210987654321
Result = 22222222112222222211
How Big Integer Calculator Works
a + b, a - b, a x b, a / b (with remainder), a^b, a mod b, a^b mod m, gcd(a, b), lcm(a, b), n!, floor(sqrt(n)), base conversion, primality
Every operation is exact integer arithmetic on JavaScript BigInt, so no digit is ever rounded. Addition, subtraction and multiplication give the full result. Division truncates toward zero and shows the remainder, so quotient x divisor + remainder always gives back the first number. The modulo operation returns the mathematical remainder, always between 0 and the divisor minus 1. Modular exponentiation a^b mod m uses square-and-multiply: it walks the bits of the exponent and reduces mod m after every step, so it never builds the astronomically large power a^b.
GCD uses the Euclidean algorithm, LCM is |a x b| divided by the GCD, and the modular inverse uses the extended Euclidean algorithm. The integer square root uses Newton's method. The primality test is Miller-Rabin with the prime bases 2 to 41. To keep your browser responsive, every operation has a digit limit, and powers and factorials have an exponent limit and a 10,000-digit result limit; a clear message tells you when you reach one.
- a, b
- Operands — The integers to operate on. They can be positive or negative and can have thousands of digits. Only whole numbers are accepted; BigInt has no decimals. Enter plain digits with an optional leading minus sign.
- m
- Modulus — For modular exponentiation, the number that results are reduced by. The answer always lies between 0 and m - 1.
- Digit Count
- Result Length — How many digits the result has. Each extra digit multiplies the size by 10, so the digit count is the quickest way to see the magnitude of a result.
- Remainder
- Division Remainder — For division, what is left over after the whole-number quotient. For integer square root, how far the input is above the nearest perfect square below it.
Worked Examples
A developer is checking a key-generation routine and multiplies two 25-digit numbers, 1,234,567,890,123,456,789,012,345 and 9,876,543,210,987,654,321,098,765, to confirm the library returns the exact product.
a = 1234567890123456789012345 · b = 9876543210987654321098765 · op = multiply
12193263113702179522618496034720321071359549253925 (50 digits)
The exact product has 50 digits. A plain JavaScript Number would give about 1.219326311370218e+49, keeping only the first 16 or so digits, so it could never confirm the library's answer.
A teacher wants to show how fast exponents grow and computes 2^100 exactly.
a = 2 · b = 100 · op = power
1267650600228229401496703205376 (31 digits)
2^100 = 1,267,650,600,228,229,401,496,703,205,376, a 31-digit number. A plain Number shows 1.2676506002282294e+30, which keeps only the first 17 digits.
A student asks how many digits 100 factorial has, and what they are.
a = 100 · op = factorial
93326215443944152681…000000 (158 digits)
100! has 158 digits and ends in 24 zeros, because there are 24 factors of 5 among 1 to 100. The exact value is far beyond what a Number can hold, since a Number overflows at 171!.
A textbook modular exponentiation example: compute 4^13 mod 497.
a = 4 · b = 13 · m = 497 · op = modpow
445
The direct power 4^13 = 67,108,864 is small here, but the same square-and-multiply method gives the answer for exponents with hundreds of digits without ever forming the full power. Four squaring steps are enough for the exponent 13 (binary 1101).
Find the greatest common divisor and least common multiple of 1071 and 462 (a classic Euclidean algorithm example).
a = 1071 · b = 462 · op = gcd
21
gcd(1071, 462) = 21, so lcm(1071, 462) = 1071 x 462 / 21 = 23,562. Switching the operation to LCM gives that directly.
Understanding the Result
A big integer calculator (also called a big int, bigint, bignum or arbitrary-precision calculator) does exact arithmetic on whole numbers of any size. Ordinary calculators and the JavaScript Number type store numbers as 64-bit floating-point values, which hold integers exactly only up to 2^53 - 1 = 9,007,199,254,740,991 (Number.MAX_SAFE_INTEGER). Beyond that, digits are silently rounded away: in plain JavaScript, 9007199254740991 + 2 gives 9007199254740992. BigInt, added to JavaScript in ES2020, stores integers exactly at any size, the way Python ints and Java BigInteger do.
That is what cryptography needs: an RSA modulus of 2048 bits has 617 digits, and the operations behind it, such as modular exponentiation, modular inverse and GCD, must be exact. This calculator covers the whole toolbox in one place: the five basic operations, modulo, a^b mod m, modular inverse, GCD and LCM, factorials, integer square roots, base conversion between 2 and 36, and a primality test. Integers are exact, which is why they behave differently from decimals: 0.1 + 0.2 is 0.30000000000000004 in floating point because 0.1 and 0.2 have no exact binary form, but 1 + 2 is always exactly 3 however long the numbers get.
The digit count, digit groups and scientific notation help you judge magnitude at a glance; the comparison row shows what a plain Number would have given you.
How to Use
- Type or paste a whole number into Value 1. Pasting numbers with hundreds or thousands of digits works; every digit is kept.
- Pick an operation. Add, subtract, multiply, divide with remainder and power are the basics; modulo, modular exponentiation, modular inverse, GCD, LCM, factorial, integer square root, base conversion and primality testing are the number theory tools.
- Fill in Value 2 (the divisor, exponent, modulus or target base). Factorial, square root and the primality test only need Value 1, and modular exponentiation also asks for the modulus m.
- Read the exact result, the same result grouped in threes, its digit count, scientific notation and a comparison with what a plain JavaScript Number would show.
- Open the worked solution under the result to see the calculation written out with your own numbers.
- Limits keep the page responsive: up to 10,000 digits per number (1,000 for modular exponentiation, 5,000 for GCD, LCM and modular inverse, 300 for the primality test), exponents up to 10,000, factorials up to 3,000! and results up to 10,000 digits.
Quick Reference
| 2^53 − 1 (Number.MAX_SAFE_INTEGER) | 9,007,199,254,740,991: the last integer a JavaScript Number holds exactly |
| 2^63 − 1 | 9,223,372,036,854,775,807: largest signed 64-bit integer |
| 2^64 | 18,446,744,073,709,551,616: one more than the largest unsigned 64-bit integer |
| 2^128 | ≈ 3.402823669 × 10^38 (39 digits) |
| 2^256 | ≈ 1.157920892 × 10^77 (78 digits) |
| 2^1024 | ≈ 1.797693134 × 10^308 (309 digits) |
| 10^100 (googol) | 101 digits (1 followed by 100 zeros) |
| 10! | 3,628,800 |
| 20! | 2,432,902,008,176,640,000: the largest factorial that fits in a signed 64-bit integer |
| 25! | ≈ 1.551121004 × 10^25 (26 digits) |
| 30! | ≈ 2.652528598 × 10^32 (33 digits) |
| 100! | ≈ 9.332621544 × 10^157 (158 digits) |
| 170! | ≈ 7.257415615 × 10^306 (307 digits): the largest factorial a JavaScript Number can hold (171! becomes Infinity) |
| 1000! | ≈ 4.023872600 × 10^2567 (2,568 digits) |
| Largest exponent for a^b | 10,000 (result up to 10,000 digits) |
| Largest n for n! | 3,000 (9,131 digits) |
Frequently Asked Questions
- What is a big integer calculator?
- A big integer calculator (also called a big int, bigint or arbitrary-precision calculator) does exact arithmetic on whole numbers that are too large for an ordinary calculator or for a programming language's normal number type. Add, subtract, multiply, divide with remainder, raise to a power, take a modulus, find a GCD, a factorial or a modular exponentiation, and every digit of the answer is exact. This one uses JavaScript BigInt, so nothing is rounded.
- What is the largest number a calculator can handle?
- It depends on how the calculator stores numbers. Most calculators and the JavaScript Number type use 64-bit floating point, which holds whole numbers exactly only up to 2^53 - 1 = 9,007,199,254,740,991 (Number.MAX_SAFE_INTEGER) and can represent magnitudes up to about 1.8 x 10^308 (Number.MAX_VALUE), but only about 16 significant digits of them. A big integer calculator has no such fixed ceiling: this one handles numbers of up to 10,000 digits, exactly, and tells you if a result would be larger.
- What is BigInt in JavaScript?
- BigInt is a JavaScript primitive type for integers of any size. You create one by adding n to an integer literal (9007199254740993n) or calling BigInt("9007199254740993"). Arithmetic on BigInts is exact, division truncates toward zero, and BigInt values cannot be mixed with ordinary Numbers in arithmetic without converting one of them. MDN recommends using BigInt when values above 2^53 are reasonably expected.
- Why is 0.1 + 0.2 not 0.3, while integers here are always exact?
- Floating-point numbers store values in binary, and 0.1 and 0.2 have no exact binary form, so 0.1 + 0.2 comes out as 0.30000000000000004. Whole numbers are different: every integer up to 2^53 - 1 is stored exactly in a floating-point Number, and a BigInt stores any integer exactly at any size. So 1 + 2 is exactly 3, and 9007199254740991 + 2 is exactly 9007199254740993 here, whereas a plain Number gives 9007199254740992. If you need decimals, work in whole units (cents, not dollars) and divide at the end.
- How many digits are in 100 factorial?
- 100! has 158 digits and ends with 24 zeros. For comparison, 20! = 2,432,902,008,176,640,000 is the largest factorial that fits in a signed 64-bit integer, 25! has 26 digits, 30! has 33 digits, and 1000! has 2,568 digits. Choose Factorial, enter n in Value 1, and the calculator shows every digit and the digit count (n up to 3,000).
- How do I calculate a power mod m (modular exponentiation)?
- Choose "Modular exponentiation", enter the base in Value 1, the exponent in Value 2 and the modulus in m. The calculator uses square-and-multiply: it reads the exponent in binary and reduces mod m after each step, so it never builds the full power. For 4^13 mod 497 the answer is 445. This is how RSA encryption and decryption work, and it handles numbers of up to 1,000 digits.
- How big a number can this calculator handle?
- Up to 10,000 digits per number for add, subtract, multiply, divide, power, modulo, square root and base conversion; 5,000 for GCD, LCM and modular inverse; 1,000 for modular exponentiation; 300 for the primality test. Powers allow exponents up to 10,000, factorials go up to 3,000! (9,131 digits), and any result is limited to 10,000 digits. These limits keep the page fast; a message tells you when you hit one.
- What happens when I divide two big integers?
- Division returns a whole-number quotient truncated toward zero and the remainder, so quotient x divisor + remainder always equals the first number. The remainder takes the sign of the dividend, as in C, Java and JavaScript: -7 / 2 gives quotient -3 and remainder -1. Python's // and % floor instead, giving -4 and 1. For a remainder that is never negative, use the Modulo operation.
- Does BigInt support decimal numbers?
- No. BigInt holds integers only. For large decimal arithmetic you would use a decimal library, or scale your numbers to whole units first (cents instead of dollars, millimetres instead of metres), calculate with exact integers and divide at the end. This calculator rejects decimals and scientific notation with a clear message instead of silently rounding.
- Can I trust the primality test?
- The test is Miller-Rabin using the first 13 prime bases (2 to 41). For numbers below 3,317,044,064,679,887,385,961,981 that set of bases is proven to give a correct yes or no, and the calculator says "Prime" or "Not prime". Above that bound it says "Probably prime" when the number passes, which is very strong evidence but not a proof. A "Not prime" verdict is always certain.
- How does this compare with Python's arbitrary-precision integers?
- Python ints are arbitrary precision by default, and results here match them for add, subtract, multiply, power, modulo with a positive divisor, GCD, factorial and modular exponentiation. Two differences: Python's // and % floor toward negative infinity, while division here truncates toward zero (use Modulo for Python's non-negative remainder), and BigInt literals need an n suffix in JavaScript.
Common Uses
- •Cryptography: checking RSA moduli, public exponents and Diffie-Hellman values with modular exponentiation, modular inverses and GCD, all exact
- •Number theory: testing primes and Mersenne numbers, finding GCD and LCM, and exploring modular arithmetic
- •Combinatorics: exact factorials and, with a division, exact binomial coefficients that floating point cannot give
- •Programming: reproducing what BigInt, Python int or Java BigInteger should return, and checking test vectors across the 2^53 and 2^64 boundaries
- •Teaching: showing that floating point silently loses digits while integers stay exact
Pro Tips
- →Use the digit count as a sanity check: a product has about as many digits as the two factors combined, and a^b has about b x log10(a) digits.
- →For RSA-style work, use modular exponentiation, not Power: a^b mod m stays small while a^b would have millions of digits. Square-and-multiply needs only about one squaring per bit of the exponent.
- →The modulo operation here always returns a value from 0 to the divisor minus 1, like Python's % with a positive divisor. The remainder shown for division follows the dividend's sign instead (like C, Java and JavaScript %), so -7 / 2 gives quotient -3 and remainder -1, while -7 mod 2 gives 1.
- →To see a number in hexadecimal or binary, enter it in decimal and choose the base conversion with base 16 or 2. The converter goes from decimal to any base from 2 to 36; to read a hex value, convert it to decimal first.
- →A "Probably prime" verdict for numbers above 3,317,044,064,679,887,385,961,981 is strong evidence, not a proof. Below that bound the test is a proof.
Limitations to Know
- •Integers only. BigInt has no decimals or fractions; to work with large decimals, scale by a power of 10 (cents instead of dollars) and divide at the end.
- •Size limits protect your browser: 10,000 digits per number (1,000 for modular exponentiation, 5,000 for GCD, LCM and modular inverse, 300 for the primality test), exponent up to 10,000, factorial up to 3,000, and results up to 10,000 digits. The calculator tells you which limit you hit.
- •Division and the remainder truncate toward zero, which differs from Python's floor division for negative numbers. Use the Modulo operation for a non-negative remainder.
- •Primality testing is Miller-Rabin with fixed bases. It is a proof below 3,317,044,064,679,887,385,961,981; above that it reports "Probably prime", which is not a mathematical certificate. It does not factor numbers; use the Prime Factorization calculator for that.
- •Base conversion starts from a decimal input and supports bases 2 to 36. It does not read hexadecimal or binary input directly.
Cite this calculator
TheCalcUniverse. "Big Integer Calculator: Exact BigInt, Mod, GCD, n!." TheCalcUniverse, 2026, https://thecalcuniverse.com/math/big-number-calculator/. Accessed October 25, 2026.
Embed this calculator on your site
You may also like
-
Mathematics
Basic Calc
A full-featured basic calculator with number pad, history tape, and order-of-operations support. Perfect for quick calculations with a running log.
Open calculator → -
Mathematics
Scientific Calc
Full-featured online scientific calculator with trigonometric functions, logarithms, memory operations, and calculation history.
Open calculator → -
Mathematics
Exponent Calculator
Raise any base to any power, including negative, fractional and decimal exponents, with expanded form, scientific notation and power rules.
Open calculator → -
Mathematics
Binary & Hex
Convert between Decimal, Binary, Hex, and Octal with positional value breakdown. Perform arithmetic and bitwise operations (AND, OR, XOR, NOT, shifts).
Open calculator → -
Mathematics
Factorial Calculator
Calculate the factorial of any number from 0 to 170. Shows the step-by-step multiplication, digit count, and trailing zeros.
Open calculator → -
Mathematics
Prime Factors
Break any integer into its unique prime factors with an interactive factor tree. Detects perfect squares, cubes, and handles numbers up to one million.
Open calculator →