Multiple Sum Calculator

Sum of all multiples of k, or of k₁ or k₂, below or up to N, by inclusion–exclusion.

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

Enter the divisors and the range

Enter your values below to get started.

Examples:
1 to 8 positive whole numbers, separated by commas.
Count multiples from this value (1 = from the start).
Range
Count numbers divisible by
Reset restores the default values.

Tips for this calculator

Below N excludes N itself; Project Euler problem 1 uses "below 1,000".

The sum of the multiples of k up to N is k·m(m + 1)/2 with m = ⌊N/k⌋.

For OR, numbers divisible by 2 of the k are counted once: the calculator subtracts the multiples of their LCM.

AND means multiples of the least common multiple (LCM): 4 and 6 → multiples of 12.

A multiple sum calculator adds every multiple of one or more numbers in a range, so the multiples of 3 or 5 below 1,000 add up to 233,168. Enter up to 8 divisors, choose "any of" (OR) or "all of" (AND), set N and the start value, and get the exact sum, the count, each inclusion–exclusion term and a running-sum chart, even for N with 30 digits.

What is a Multiple Sum?

A multiple sum is the total of every number in a range that is divisible by a given number k, or by at least one of several numbers. The multiples of 3 or 5 below 10 are 3, 5, 6 and 9, and their sum is 23.

Sk(N)=∑1≤x≤Nk∣xxS_k(N) = \sum_{\substack{1 \le x \le N \\ k \mid x}} x

A multiple of k is k × j for a whole number j: the multiples of 7 are 7, 14, 21, 28, …. A number divisible by 2 different divisors, such as 15 for 3 and 5, belongs to both lists but is added once. This problem opens Project Euler, the problem archive Colin Hughes started in 2001: Problem 1 asks for the sum of all multiples of 3 or 5 below 1,000.

InteractiveHighlight the multiples on a 1–100 grid

How Does the Multiple Sum Calculator Work?

The multiple sum calculator uses a closed formula for each divisor and the inclusion–exclusion principle for overlaps, so the work does not depend on N. Summing the multiples of 3 or 5 below 109 takes 3 formula evaluations instead of checking 999,999,999 numbers: 233,333,333,166,666,668.

InteractiveVenn diagram of multiples of k₁ and k₂
  1. Fix the upper limit

    Below N uses N − 1; up to N uses N. A start value a subtracts the sum up to a − 1.

  2. Count the multiples

    m = ⌊limit / k⌋ multiples of k: ⌊999 / 3⌋ = 333.

  3. Apply the formula

    k·m(m + 1)/2 = 3 × 333 × 334 / 2 = 166,833.

  4. Fix the overlaps

    Add single divisors, subtract pairs (their LCM), add triples, and so on.

Sum of Multiples Formula

The sum of the multiples of k up to N is S = k·m(m + 1)/2, where m = ⌊N/k⌋ is the number of multiples. The multiples k, 2k, …, mk are k times 1, 2, …, m, and 1 + 2 + … + m = m(m + 1)/2.

One Divisor

Sk(N)=k⋅m(m+1)2,m=⌊Nk⌋S_k(N) = k \cdot \frac{m(m+1)}{2}, \quad m = \left\lfloor \frac{N}{k} \right\rfloor

Multiples of 7 up to 100: m = 14, S = 7 × 14 × 15 / 2 = 735.

Two Divisors (OR)

Sa∨b=Sa+Sb−Slcm⁡(a,b)S_{a \lor b} = S_a + S_b - S_{\operatorname{lcm}(a,b)}

Below 1,000: 166,833 + 99,500 − 33,165 = 233,168.

Multiples in a Range [a, b]

Sk[a,b]=Sk(b)−Sk(a−1)S_k[a, b] = S_k(b) - S_k(a - 1)
Interactivek + 2k + … + mk as a staircase

Types of Multiple Sums

There are 5 types of multiple sums: multiples of one number, multiples of any of several numbers (OR), multiples of all of them (AND), multiples in a range and multiples of one number but not another. Each type reduces to the one-divisor formula.

Interactive5 kinds of multiple sums, 1 formula

One number

Multiples of 7 up to 100: 735.

Any of several (OR)

Multiples of 4 or 6 up to 100: 1,300 + 816 − 432 = 1,684.

All of several (AND)

Multiples of 4 and 6 = multiples of lcm 12: 432 up to 100.

In a range

Multiples of 7 from 50 to 150: 56 + 63 + … + 147 = 1,421.

Excluding (NOT)

Multiples of 4 but not 6 up to 100: 1,300 − 432 = 868.

How to Calculate the Sum of Multiples by Hand

To calculate the sum of multiples by hand, count the multiples with m = ⌊N/k⌋, apply k·m(m + 1)/2 to each divisor, and subtract the multiples of each pair's LCM. Here are the multiples of 3 or 5 below 1,000:

  1. Limit: below 1,000, so use 999.
  2. Multiples of 3: m = 333, sum = 3 × 333 × 334 / 2 = 166,833.
  3. Multiples of 5: m = 199, sum = 5 × 199 × 200 / 2 = 99,500.
  4. Multiples of 15 (counted twice): m = 66, sum = 15 × 66 × 67 / 2 = 33,165.
  5. Total: 166,833 + 99,500 − 33,165 = 233,168.
InteractiveStep through multiple sums by hand

    Inclusion–Exclusion for Sums of Multiples

    The inclusion–exclusion principle adds the sums for single divisors, subtracts the sums for every pair, adds them back for every triple, and so on, so each number is counted exactly once. With d divisors there are 2d − 1 terms: 3 for 2 divisors, 7 for 3, 15 for 4.

    Sk1∨⋯∨kd=∑∅≠T⊆{1..d}(−1)∣T∣+1 Slcm⁡(kT)S_{k_1 \lor \cdots \lor k_d} = \sum_{\emptyset \ne T \subseteq \{1..d\}} (-1)^{|T|+1}\, S_{\operatorname{lcm}(k_T)}

    Abraham de Moivre used the principle in 1718, and James Joseph Sylvester stated the general form in the 19th century. Each term uses the least common multiple (LCM), not the product: the overlap of 4 and 6 is the multiples of 12, not of 24.

    InteractiveSwitch divisors on and watch the terms grow

    Common Mistakes with Sums of Multiples

    • Counting overlaps twice: 15, 30, 45, … are multiples of both 3 and 5 and must be added once.
    • Using the product instead of the LCM: the overlap of 4 and 6 is lcm 12, not 24.
    • Including N when the problem says below N: multiples of 5 below 1,000 stop at 995.
    • Rounding m up: m = ⌊999 / 5⌋ = 199, not 200.
    • Looping to large N: a loop to 109 checks a billion numbers; the formula needs 3 steps.
    InteractiveTrue or false: sums of multiples
    1. The multiples of 3 or 5 below 10 add up to 23.

    2. Multiples of 4 and 6 are the multiples of 24.

    3. The sum of the multiples of 7 up to 100 is 735.

    4. "Below 1,000" includes 1,000 when 1,000 is a multiple.

    5. With 3 divisors, inclusion–exclusion needs 7 terms.

    Score: 0 / 5

    How to Use the Multiple Sum Calculator

    Enter the divisors, the limit N and the start value, choose Below N or Up to N, pick Any (OR) or All (AND) and press Calculate. The result card shows the sum, the count and the first multiples; the tabs list each step, chart the running sum and table every inclusion–exclusion term.

    InteractiveLoad a ready-made multiple sum

    Each button fills the calculator and runs it.

    1. Enter the divisors

      One number such as 7, or up to 8 numbers such as 3, 5, 7.

    2. Set the range

      Limit N, start value and Below N (<) or Up to N (≤).

    3. Choose the logic

      Any (OR) counts numbers divisible by at least one k; All (AND) needs every k.

    4. Check the terms

      The Inclusion–exclusion tab lists each LCM with its sign, count and sum.

    Real-Life Uses of Sums of Multiples

    Sums of multiples appear in programming tests, scheduling and payroll, wherever an event repeats every k steps. There are 5 common uses:

    • Coding interviews and contests: Project Euler problem 1 and the FizzBuzz test, where multiples of 3 print "Fizz" and multiples of 5 print "Buzz".
    • Scheduling: a task every 3 days and another every 5 days fall on the same day every 15 days.
    • Payroll and savings: a deposit on every 7th day of a 365-day year happens 52 times.
    • Manufacturing: inspecting every 12th or 20th item gives overlaps every 60th item.
    • Number theory: sums over multiples are the starting point of the Möbius inversion and sieve methods.
    InteractiveFizzBuzz: counts and sums of multiples

    Multiple Sum Examples

    Sums of multiples with their counts.

    Multiple Sum Examples
    MultiplesRangeCountSumCalculator
    3 or 5below 10423
    3 or 5below 1,000466233,168
    7up to 10014735
    4 or 6up to 100331,684
    4 and 6up to 1008432
    2 or 3below 100663,317
    9100 to 5004413,266

    Popular Multiple Sum Problems

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

    1. Find the sum of all multiples of 3 or 5 below 1,000 (Project Euler 1).

      Show answer233,168
    2. Find the sum of the multiples of 7 up to 1,000.

      Show answer71,071 (142 multiples)
    3. Find the sum of the numbers up to 200 divisible by both 6 and 8.

      Show answer864 (multiples of 24)
    4. Find the sum of all 3-digit multiples of 11.

      Show answer44,550 (81 multiples)
    5. Find the sum of the multiples of 3, 5 or 7 below 1,000.

      Show answer271,066
    6. Find the sum of all multiples of 3 or 5 below 1,000,000,000.

      Show answer233,333,333,166,666,668

    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 a multiple sum calculator?

    A multiple sum calculator is an online tool that adds every multiple of one or more numbers in a range. This calculator handles up to 8 divisors with OR or AND logic, below or up to N, from any start value.

    What is the sum of all multiples of 3 or 5 below 1000?

    The sum of all multiples of 3 or 5 below 1,000 is 233,168: 166,833 for 3, plus 99,500 for 5, minus 33,165 for 15.

    What is the formula for the sum of multiples of k?

    The sum of the multiples of k up to N is k·m(m + 1)/2, where m = ⌊N/k⌋. For k = 7 and N = 100, m = 14 and the sum is 735.

    Why subtract the multiples of 15?

    Multiples of 15 are multiples of both 3 and 5, so adding the 2 lists counts each of them twice. Subtracting the multiples of 15 once fixes the double count.

    Is "below N" the same as "up to N"?

    No, below N excludes N and up to N includes N. They differ only when N itself is a multiple: multiples of 5 below 100 add to 950, and up to 100 add to 1,050.

    How many multiples of k are there below N?

    There are ⌊(N − 1)/k⌋ multiples of k below N. Below 1,000 there are 333 multiples of 3 and 199 multiples of 5.

    Can the calculator handle very large N?

    Yes, the calculator uses exact BigInt formulas, so N can have up to 30 digits and the answer appears instantly.

    What does the LCM have to do with sums of multiples?

    A number is a multiple of both a and b exactly when it is a multiple of lcm(a, b). The overlap of 4 and 6 is the multiples of 12.

    How do you sum multiples of k between a and b?

    Subtract the sum up to a − 1 from the sum up to b. Multiples of 7 from 50 to 150: 1,617 − 196 = 1,421.

    Conclusion

    A multiple sum adds every multiple of k in a range, and the formula k·m(m + 1)/2 with inclusion–exclusion gives the answer for any number of divisors without listing a single multiple. The multiple sum calculator applies those formulas exactly, shows every term and handles N up to 30 digits.

    Not sure which settings to use? Answer 3 questions below.

    InteractiveWhich multiple sum settings fit your problem?