Divisible by 2 and 5

The sum of integers from 1 to 100 inclusive which are divisible by 2 or 5 (or both) is


The answer is 3050.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

8 solutions

Rahma Anggraeni
May 2, 2014

The '2 multiple' there are 50 terms, because 100 2 = 50 \frac{100}{2} = 50 . Then a a is the first term and b b is the difference between each term.

S 50 = n 2 ( 2 a + ( n 1 ) b ) S_{50} = \frac{n}{2}(2a + (n-1)b)

S 50 = 50 2 ( 2 × 2 + ( 50 1 ) 2 ) S_{50} = \frac{50}{2}(2 \times 2 + (50-1)2)

S 50 = 50 ( 2 + 49 S_{50} = 50(2+ 49

S 50 = 2550 S_{50} = 2550

Then the term that can divided by 5 but can't be divided by 2 because the terms have been included in the '2 multiple' terms.

5 + 15 + 25 + 35 + 45 + 55 + 65 + 75 + 85 + 95 = 500 5+15+25+35+45+55+65+75+85+95= 500

So, 2550 + 500 = 3050 2550+500=\boxed{3050}

2(1+2+3+4+...+50) = 2550

5(1+2+3+...+20) = 1050

(multiples of 2 & 5) 10(1+2+...+10) = 550

Apply Inclusion-Exclusion Principle, i.e., 2550+1050-550=3050.

Thus, the answer is 3050.

Excellent solution!

Jiri R. - 7 years, 1 month ago

Truely superb

Sohel Rana - 7 years ago
Sachin Kumar
May 4, 2014

include<stdio.h>

void main()  {
int i,j,k,sum;
int a[100];
for(i=2,k=0;i<=100;i++) {
    if(i % 2== 0 || i%5==0) {

        a[k]=i;
        k++;
    }
}
for(j=sum=0;j<k;j++)
    sum+=a[j];
    printf("\n\n%d,",sum);
}

waow :)

Syeda Faixa Abidi - 7 years, 1 month ago

I know it's fun to write programs to do stuff but this really isn't a Computer Science problem!

Connor Kenway - 7 years, 1 month ago
Uahbid Dey
May 2, 2014

S = 2 + 4 + 5 + 6 + 8 + 10 + 12 + 14 + 15 + 16 + .........+100 = (2 + 4 + 6 + 8 + 10 + ..... + 100) + (5 + 15 + 25 + ..... + 95) = 2x(1+2+3+4+.....+50) + 5(1+3+5+......+19) = (2x½ x 50 x 51) + {5x½x(1+19)x10} = 2550 + 500 = 3050

I did something similar. I first found the pattern in the first 10 numbers set (2,4,5,6,8,10). We already know that it is going to follow as a series (i.e. 12,14,15,16,18,20 and continue 22,24,25,26,28,30 and so on). Now 2+4+5+6+8+10 is 35. For every 10 sets until 100, there is a jump of 60 (since there are 6 numbers in each set). So for the first set jump is 0 (total sum for this set: 0+35=35), second jump: 60 (total sum for this set: 60+35), third jump: 120 (total sum for this set: 120+35) and so on. now once the pattern is got it is easy.

the final answer X = 2 + 4 + 5 + 6 + 8 + 10 + 12 + 14 + 15 + 16 + 18 + 20 + 22 +....

from the above set based jump, X = 35*10 (for the 10 sets) + 60 (0+1+2+3...9) again jump for each of the 10 sets.

hence X = 350 + 60 ((9+10)/2) == 3050!

Hemant Krishnan - 7 years, 1 month ago
Vishnudatt Gupta
Apr 30, 2014

sum of integers from 1 to 100 that are divisible by 2 =n(n+1) =50*51 =2550 sum of integers from 1 to 100 that are divisible by 5 but not divisible by 2. are 5,15,.25,----------95 = 10/2 (5+95) = 500 The sum of integers from 1 to 100 that are divisible by 2 or 5 is=2550+500=3050 Ans

Your solution answers the question for "2 or 5" instead of "2 and 5".


I have since edited the problem to be properly phrased. Those who previously answered 450 or 550 have also been marked correct.

Calvin Lin Staff - 7 years, 1 month ago

S n = 3 n 2 + 5 n 10 S_n=\frac{3n^2+5n}{10}

Aronas Nuresi - 7 years, 1 month ago
Shubham Gaikwad
May 24, 2014
1
2
3
4
5
6
7
var sum=0;
for (var i=1;i<=100;i++) 
{
 if( (i%2==0) || (i%5==0) ) 
         sum+=i; 
 } 
console.log(sum); 

JavaScript code ( can run in browser console )

Madhukar Thalore
May 11, 2014

First sum digits divisible by 2 which is 2550. Then sum the digits divisible by 5 which is 1050. now subtract digits common to both which are digits divisible by 10 which is 550. therefore answer is 2550+1050-550=3050.

sum to 50 even numbers(since there are only 50 even numbers from 1 to 100) is 2550 [ using S_50 = 50/2 (2x2 + 49x2) ]
sum of numbers which are not divisible by 5 but divisible by 2 is
2550 - 10 (1+2+3+5+6+7+8+9+10) = 2000
the number of numbers divisible by 5 from 1 to 100 is 20. The sum of such numbers is (using the same formula above used) is 1050. Hence the sum of numbers that are divisible by 2 and 5 from 1 to 100 is 2000+1050 = 3050


0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...