1

What is the sum of all integers between 1 and 6000 which are aren't divisible by 5 or 4?

The only method I could think of is finding all the multiples of 4 and 5 between 1 and 6000 and adding them together. Then finding the sum of all the numbers from 1 to 6000 and subtracting the other sum from this sum to find the answer. But this method isn't at all efficient so can you please help me in finding a method that is efficient?

Valerie
  • 95

1 Answers1

2

Sum all the numbers from $1$ to $6000$. The sum of all the multiples of $4$ is four times the sum of all the numbers from $1$ to $1500$. Subtract that. Subtract the sum of all the multiples of $5$. Now the multiples of $20$ .... This is called the inclusion-exclusion principle.

Ross Millikan
  • 374,822