Gauss Sum Calculator

1 + 2 + … + n with Gauss's formula, any range a to b, and quadratic Gauss sums g(a; n).

  1. Enter valuesUse your own inputs or an example
  2. CalculateApply your selected settings
  3. View resultExplore the answer and explanation

Choose a Gauss sum and enter the numbers

Enter your values below to get started.

Examples:
What do you want to add?
Whole number from 1 up to 40 digits.
Negative values are allowed.
1 to 200,000. Odd primes give the classic case.
Reset restores the default values.

Tips for this calculator

Type huge values such as 10^20 as digits: 100000000000000000000. The answer stays exact.

The sum from a to b equals Tb − Ta−1, where Tn = n(n + 1)/2.

A range with as many negative terms as positive terms, such as −10 to 10, adds to 0.

For g(a; n), pick an odd prime n such as 5, 7, 11 or 13 to see Gauss's √n result.

A Gauss sum calculator adds the whole numbers 1 + 2 + … + n in one step with the formula n(n + 1)/2. Enter n to get the sum, or enter a first and last term to add any run of consecutive integers, including negative ones. A third mode evaluates the quadratic Gauss sum g(a; n) from number theory and draws its path in the complex plane.

What is a Gauss Sum?

A Gauss sum is the total of the consecutive whole numbers 1 + 2 + 3 + … + n, found with the formula n(n + 1)/2 instead of adding term by term. The sum 1 + 2 + … + 100 equals 100 × 101 / 2 = 5,050.

1+2+3+⋯+n=∑k=1nk=n(n+1)21 + 2 + 3 + \cdots + n = \sum_{k=1}^{n} k = \frac{n(n+1)}{2}

The name comes from Carl Friedrich Gauss (1777–1855). Biographer Wolfgang Sartorius von Waltershausen wrote in 1856 that young Gauss, set the task of adding 1 to 100 by teacher J. G. Büttner in Brunswick, wrote 5,050 on his slate within moments. Gauss saw that 1 + 100, 2 + 99, 3 + 98 and every other pair add to 101, and that 100 numbers make 50 such pairs.

In number theory, the term Gauss sum names a second object: the quadratic Gauss sum g(a; n) = Σ e2πi·a·k²/n, a sum of complex roots of unity. The calculator handles both meanings.

InteractivePair 1 … n with n … 1 the way Gauss did

How Does the Gauss Sum Calculator Work?

The Gauss sum calculator counts the terms, adds the first and last term, multiplies the two results and divides by 2. All 3 operations run on exact whole numbers (JavaScript BigInt), so a 40-digit n gives every digit of the answer with no rounding.

InteractiveTwo staircases of dots fill an n × (n + 1) rectangle
  1. Count the terms

    From 1 to n there are n terms; from a to b there are b − a + 1 terms.

  2. Add first and last

    1 + n, or a + b. Every mirrored pair has this same total.

  3. Multiply and halve

    S = (number of terms) × (first + last) / 2.

  4. Show the proof

    The steps tab writes the sum forward and backward, and the chart tab draws the two staircases of dots.

Gauss Sum Formula

The Gauss sum formula is S = n(n + 1)/2 for 1 + 2 + … + n, and S = N(a + b)/2 for the N consecutive integers from a to b. Both formulas say the same thing: the sum equals the number of terms times the average term.

Sum of the First n Natural Numbers

Tn=∑k=1nk=n(n+1)2T_n = \sum_{k=1}^{n} k = \frac{n(n+1)}{2}

Tn is the n-th triangular number: T10 = 55, T100 = 5,050, T1000 = 500,500.

Sum of Consecutive Integers from a to b

∑k=abk=(b−a+1)(a+b)2=Tb−Ta−1\sum_{k=a}^{b} k = \frac{(b-a+1)(a+b)}{2} = T_b - T_{a-1}

For 50 to 100: N = 51 terms, a + b = 150, S = 51 × 150 / 2 = 3,825.

Quadratic Gauss Sum Formula

g(a; n)=∑k=0n−1e2πi ak2/ng(a;\,n) = \sum_{k=0}^{n-1} e^{2\pi i\, a k^2 / n}

For an odd prime p, g(1; p) = √p when p ≡ 1 (mod 4) and i√p when p ≡ 3 (mod 4).

InteractiveFormula playground: S = N(a + b)/2

Types of Gauss Sums

There are 5 common types of Gauss sums: the classic 1 to n sum, a range of consecutive integers, the sum of odd numbers, the sum of even numbers or multiples, and the quadratic Gauss sum of number theory. The first 4 types are arithmetic series that Gauss's pairing trick solves; the fifth type is a sum of complex numbers.

InteractiveSwitch the type of Gauss sum and watch the total

Classic sum 1 to n

1 + 2 + … + n = n(n + 1)/2. Example: 1 + … + 100 = 5,050.

Range a to b

(b − a + 1)(a + b)/2. Example: 101 + … + 200 = 15,050.

Odd numbers

1 + 3 + … + (2n − 1) = n². Example: the first 10 odd numbers add to 100.

Even numbers and multiples

2 + 4 + … + 2n = n(n + 1); 5 + 10 + … + 5n = 5n(n + 1)/2.

Quadratic Gauss sum g(a; n)

Σ e2πi·a·k²/n. For an odd prime p, |g(1; p)| = √p.

How to Calculate a Gauss Sum by Hand

To calculate a Gauss sum by hand, count the terms, add the first and last term, multiply those 2 numbers and divide by 2. Here is 1 + 2 + … + 100:

  1. Number of terms: n = 100.
  2. First + last: 1 + 100 = 101.
  3. Multiply: 100 × 101 = 10,100.
  4. Divide by 2: 5,050.

Divide the even factor first to keep the numbers small: for n = 1,000, compute 500 × 1,001 = 500,500.

InteractiveStep through 3 Gauss sums by hand

    Gauss Sums and Triangular Numbers

    Every Gauss sum 1 + 2 + … + n is a triangular number Tn, the number of dots in a triangle with n rows. The first 10 triangular numbers are 1, 3, 6, 10, 15, 21, 28, 36, 45 and 55.

    To test whether a number S is triangular, solve n(n + 1)/2 = S for n:

    n=−1+1+8S2n = \frac{-1 + \sqrt{1 + 8S}}{2}

    S is triangular exactly when 1 + 8S is a perfect square. For S = 5,050, 1 + 8S = 40,401 = 201², so n = 100. Gauss recorded in his diary on 10 July 1796 that every whole number is the sum of at most 3 triangular numbers (“ΕΥΡΗΚΑ! num = Δ + Δ + Δ”).

    InteractiveIs your number a Gauss sum? Triangular number test

    Quadratic Gauss Sum in Number Theory

    A quadratic Gauss sum g(a; n) adds the n complex numbers e2πi·a·k²/n for k = 0 to n − 1, and for a = 1 its value is always √n times 1, i, 1 + i or 0. Gauss studied these sums in Disquisitiones Arithmeticae (1801) and proved the sign of the answer in 1805, after 4 years of attempts.

    g(1; n)={(1+i)nn≡0(mod4)nn≡1(mod4)0n≡2(mod4)inn≡3(mod4)g(1;\,n) = \begin{cases} (1+i)\sqrt{n} & n \equiv 0 \pmod 4 \\ \sqrt{n} & n \equiv 1 \pmod 4 \\ 0 & n \equiv 2 \pmod 4 \\ i\sqrt{n} & n \equiv 3 \pmod 4 \end{cases}

    For an odd prime p and a not divisible by p, g(a; p) = (a/p)·g(1; p), where (a/p) is the Legendre symbol (+1 or −1). Example: (2/13) = −1, so g(2; 13) = −√13 ≈ −3.6056. Quadratic Gauss sums give one of the proofs of the law of quadratic reciprocity.

    InteractiveDraw g(a; n) as a walk of unit steps in the complex plane

    Common Mistakes with Gauss Sums

    • Forgetting to divide by 2: n(n + 1) is twice the sum. 100 × 101 = 10,100, not the answer 5,050.
    • Miscounting the terms: the integers from a to b number b − a + 1, not b − a. From 21 to 40 there are 20 terms.
    • Using n(n + 1)/2 for a range: 50 + … + 100 is T100 − T49 = 3,825, not T100 − T50.
    • Applying the formula to squares: 1² + 2² + … + n² = n(n + 1)(2n + 1)/6, a different formula.
    • Mixing up the 2 meanings: the quadratic Gauss sum g(a; n) is a complex number, not 1 + 2 + … + n.
    InteractiveTrue or false: Gauss sums
    1. 1 + 2 + … + 100 = 5,050.

    2. There are 20 integers from 20 to 40.

    3. The sum of the first n odd numbers is n².

    4. n(n + 1)/2 can be a fraction for some whole number n.

    5. The quadratic Gauss sum g(1; 10) equals 0.

    Score: 0 / 5

    How to Use the Gauss Sum Calculator

    Pick a mode, type the numbers and press Calculate. The result shows the exact sum, the number of terms and the average term; the tabs hold the pairing steps, a table of running totals and a chart.

    InteractiveLoad a ready-made Gauss sum

    Each button fills the calculator and runs it.

    1. Pick the mode

      1 + 2 + … + n, From a to b, or Quadratic Gauss sum g(a; n).

    2. Enter the numbers

      n for the classic sum; a and b for a range; modulus n and coefficient a for g.

    3. Press Calculate

      The sum appears with thousands separators; Copy puts the plain digits on the clipboard.

    4. Check the steps

      Open Step-by-step to see the forward-and-backward proof with your numbers.

    Real-Life Uses of the Gauss Sum

    The Gauss sum counts anything that grows by 1 at each step or pairs every item with every other item. There are 5 everyday uses:

    • Handshakes: n people who each shake hands once make n(n − 1)/2 handshakes; 30 people make 435.
    • Round-robin tournaments: 20 football teams that meet once play 190 games, 380 in a home-and-away league.
    • Stacking: a pyramid of cans with 10 in the bottom row holds 55 cans.
    • Saving plans: saving $1 on day 1, $2 on day 2 and so on for 365 days gives $66,795.
    • Algorithm analysis: a nested loop that compares every pair of n items runs n(n − 1)/2 times, the O(n²) cost of bubble sort.
    InteractiveGauss sum scenarios: handshakes, games, cans, savings

    Gauss Sum Examples

    Common Gauss sums with their exact values. Click a row to load it.

    Gauss Sum Examples
    SumTermsValueCalculator
    1+2+⋯+101 + 2 + \cdots + 101055
    1+2+⋯+1001 + 2 + \cdots + 1001005,050
    1+2+⋯+10001 + 2 + \cdots + 10001,000500,500
    1+2+⋯+3651 + 2 + \cdots + 36536566,795
    50+51+⋯+10050 + 51 + \cdots + 100513,825
    −5+(−4)+⋯+12-5 + (-4) + \cdots + 121863
    g(1; 5)g(1;\,5)5√5 ≈ 2.2361
    g(1; 7)g(1;\,7)7i√7 ≈ 2.6458i

    Popular Gauss Sum Problems

    Try each one, then reveal the answer or solve it in the calculator.

    1. Add the whole numbers from 1 to 50.

      \sum_{k=1}^{50} k
      Show answer1{,}275
    2. Add the whole numbers from 1 to 200.

      \sum_{k=1}^{200} k
      Show answer20{,}100
    3. Add the integers from 21 to 40.

      \sum_{k=21}^{40} k
      Show answer610
    4. Add the integers from −10 to 10.

      \sum_{k=-10}^{10} k
      Show answer0
    5. 25 people shake hands once with every other person. How many handshakes? (Add 1 to 24.)

      \sum_{k=1}^{24} k
      Show answer300\text{ handshakes}
    6. Evaluate the quadratic Gauss sum g(1; 11).

      g(1;\,11)
      Show answeri\sqrt{11} \approx 3.3166\,i

    Explore More Sum Calculators

    Discover 67 free sum calculators across different categories. Find the right calculator for your needs.

    Browse All 67 Calculators
    Questions and answers

    Frequently Asked Questions

    What is the Gauss sum formula?

    The Gauss sum formula is n(n + 1)/2, the total of 1 + 2 + … + n. For any run of consecutive integers from a to b, the formula is (b − a + 1)(a + b)/2.

    What is 1 + 2 + 3 + … + 100?

    1 + 2 + 3 + … + 100 = 5,050, found as 100 × 101 / 2. This is the sum young Carl Friedrich Gauss is said to have found in his Brunswick classroom.

    Did Gauss really add 1 to 100 as a child?

    Yes, the story is reported by Gauss's friend and biographer Wolfgang Sartorius von Waltershausen in 1856, though the exact numbers in the original task are not recorded. Later retellings fixed the task as 1 to 100.

    How do you find the sum of consecutive numbers?

    Multiply the number of terms by the sum of the first and last term, then divide by 2. For 21 to 40: 20 × 61 / 2 = 610.

    Is every Gauss sum a triangular number?

    Yes, 1 + 2 + … + n is the n-th triangular number T<sub>n</sub>, the number of dots in a triangle with n rows. T<sub>4</sub> = 10, the bowling-pin triangle.

    Can a Gauss sum include negative numbers?

    Yes, the formula (b − a + 1)(a + b)/2 works for any integers a ≤ b. The sum from −5 to 12 is 18 × 7 / 2 = 63.

    What is a quadratic Gauss sum?

    A quadratic Gauss sum g(a; n) is the sum of e<sup>2πi·a·k²/n</sup> for k = 0 to n − 1. For an odd prime p, g(1; p) equals √p if p ≡ 1 (mod 4) and i√p if p ≡ 3 (mod 4).

    What is the difference between a Gauss sum and an arithmetic series?

    A Gauss sum 1 + 2 + … + n is the simplest arithmetic series, with first term 1 and common difference 1. The general arithmetic series formula n(a₁ + aₙ)/2 is Gauss's pairing idea applied to any common difference.

    How large a number can the Gauss sum calculator handle?

    The Gauss sum calculator accepts n with up to 40 digits and returns every digit of the answer, since the arithmetic runs on exact integers.

    Conclusion

    The Gauss sum turns 1 + 2 + … + n into one multiplication, n(n + 1)/2, and the Gauss sum calculator applies that pairing idea to any range of integers and to the quadratic Gauss sums of number theory. Use the 1 to n mode for triangular numbers, the a to b mode for any run of consecutive integers, and the g(a; n) mode for roots-of-unity sums.

    Not sure which mode fits your problem? Answer the questions below.

    InteractiveWhich Gauss sum mode should you use?