What is the sum of all integers N , that are divisible by 3 or 5 and satisfy 1 ≤ N ≤ 6 1 ?
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.
very nice solution !
Good!
nice
I really thought this solution but... I had a pen mistake :( SO SAD.
Best solution...
The numbers divisible by 3 in the given range are 3 , 6 , 9 . . . . . . 6 0 . The sum of these numbers is
3 + 6 + 9 + . . . . . + 6 0 = 3 ( 1 + 2 + 3 + . . . . + 2 0 ) = 3 × 2 2 0 × 2 1 = 6 3 0
The numbers divisible by 5 in the given range are 5 , 1 0 , 1 5 . . . . 6 0 . The sum of these numbers is
5 + 1 0 + 1 5 + . . . . . . . + 6 0 = 5 ( 1 + 2 + . . . . . . + 1 2 ) = 5 × 2 1 2 × 1 3 = 3 9 0
The sum of integers either divisible by 3 or 5 is not simply 390+630. If we do this, we double-count those numbers divisible by both 3 and 5. In other word, we need to subtract those numbers which are divisible by 15. The numbers divisible by 15 are 1 5 , 3 0 , 4 5 and 6 0 . The sum of these numbers is
1 5 + 3 0 + 4 5 + 6 0 = 1 5 0
Hence, our final answer is 6 3 0 + 3 9 0 − 1 5 0 = 8 7 0 .
One more thing to note that 630+390>999 so that should probably give you a hint. :P
This seems like it has better explanation than Ayon Pal's one. That's just in my opinion. :)
There are 20 multiples of 3 in the given interval, so to find that sum we simply add the positive integers from 1 to 20 and multiply the result by 3; this yields N 3 = 6 3 0 .
There are 12 multiples of 5 in the given range, so we can find the sum in a similar manner: N 5 = 3 9 0 .
From these we can conclude that N 3 + N 5 = 1 0 2 0 . However, we counted multiples of 15 in both N 3 and N 5 ; hence we will subtract the multiples of 15 ( N 1 5 = 1 5 0 )from our previously obtained sum.
Therefore, the required sum is N = N 3 + N 5 − N 1 5 = 8 7 0 .
The number divisible by 3 for value N are 3 , 6 , 9 , 1 2 . . . . 6 0 which is an A.P. series.
Then the 1st number of the series a 1 = 3 ; the common difference d 1 = 3 ; the total number of the sequence n 1 = 3 6 0 = 2 0 [60 is the last number, because 61 can not divisible by 3]
So, the sum of all sequence if the A.P. s 1 = 2 n 1 [ 2 a 1 + d 1 ( n 1 − 1 ) ] ⟹ 2 2 0 [ 2 × 3 + 3 ( 2 0 − 1 ) ] ⟹ 1 0 × ( 6 + 5 7 ) ⟹ 6 3 0
Using the same method : The number divisible by 5 for value N are 5 , 1 0 , 1 5 , 2 0 . . . . 6 0 which is also an A.P. series.
Then the 1st number of the series a 2 = 5 ; the common difference d 2 = 5 ; the total number of the sequence n 2 = 5 6 0 = 1 2 [60 is the last number, because 61 is not divisible by 5]
So, the sum of all sequence if the A.P. s 2 = 2 n 2 [ 2 a 2 + d 2 ( n 2 − 1 ) ] ⟹ 2 1 2 [ 2 × 5 + 5 ( 1 2 − 1 ) ] ⟹ 6 × ( 1 0 + 5 5 ) ⟹ 3 9 0
And the number we counted twice in these two sequence are value of N from 1 t o 6 1 which are multiple of 3 × 5 o r 1 5 . And there is 4 multiples of 15 between 1 and 61 and there sum is 1 5 + 3 0 + 4 5 + 6 0 = 1 5 0
We get the sum of all integers value of N = 6 3 0 + 3 9 0 − 1 5 0 ⟹ 8 7 0
We need to find the sum of the sequences: 3 , 6 , 9 , 1 2 , 1 5 , 1 8 , 2 1 … 5 7 , 6 0 and 5 , 1 0 , 1 5 , 2 0 … 5 5 , 6 0 and subtract out the common terms. The sum of the first sequence is just 2 ( 6 0 + 3 ) 2 0 = 6 3 0 , and the sum of the second is 2 ( 5 + 6 0 ) 1 2 = 3 9 0 . Summing this gives 1 0 2 0 . Now, the common terms are multiples of 15, namely 15,30,45, and 60 within the given range. Subtracting this from 1020 gives the answer 8 7 0 , done.
The sum of numbers who are divisible by 3 in the given limits is: 3 + 6 + 9 + 1 2 + . . . . . . . + 6 0 which is an arithmetic progression with a 1 = 3 , d = 3 and n = 2 0 .Using its formula for sum we obtain S = 6 3 0 .In this sum we have also calculated the numbers which are divisible by 3 and 5 at the same time and their sum is S = 1 5 + 3 0 + 4 5 + 6 0 = 1 5 0 .The sum of numbers which are divisible by 5 is S = 5 + 1 0 + 1 5 + . . . . . . . . + 6 0 .This is also an arithmetic progression with a 1 = 5 , d = 5 and n = 1 2 .Using its formula for sum we obtain S = 3 9 0 . In this sum we have also calculated those numbers who are divisible by 3 and 5 in the same time but we have counted them once and that's why we are going to substract 1 5 0 from 3 9 0 to obtain 2 4 0 .Therefore the desired sum is 6 3 0 + 2 4 0 = 8 7 0 .
integers that are divisible by 3 from 1 to 61 are an Arithmetic Progression starts from 3 and ends at 60 with an increment of 3 then their summation are S = n(a + L)/2 = 20*(3+60)/2=630
integers that are divisible by 5 from 1 to 61 are an Arithmetic Progression starts from 5 and ends at 60 with an increment of 5 then their summation are S = n(a + L)/2 = 12*(5+60)/2=390
integers that are divisible by 5 and 3 from 1 to 61 are an Arithmetic Progression starts from 5x3=15 and ends at 60 with an increment of 15 then their summation are S = n(a + L)/2 = 4*(15+60)/2=150
so the required summation is =630+390-150=870
Integers between 1 and 61 which are divisible by 3 and 5.
Integers divisible by 3 are 3,6,9,...60. (20 terms). Sum = 630
Integers divisible by 5 are 5,10,15,...60 (12 terms). Sum =390. And we can see that multiples 15 are counted twice in multiples of 3 & 5 both.
Therefore, multiples of 15 (Sum = 150) should be removed from the sum of multiples of 3 & 5.
Net sum = 630 + 390 - 150 = 870. (Ans)
Hello all,
as the range for N is [1,61],
we know that N is divisible by 3 or 5,the numbers that are divisible by both 3 & 5 are 15,30,45 and 60,
therefore,for N divisible by 3 are 3,6,9,12,........60,
60/3=20(20 terms up to 60),
S(20 terms)=20/2.[2(3)+(19)(3)]=630(amongst the sum included the sum of 15,30,45,60 together),
as for N that is divisible by 5,we know that the N are = 5,10,15,20,25,30,35,40,45,60(but we already added up for 15,30,45,60),sum of N/5=5+10+20+25+35+40+50+55=240
Therefore, N(sum of integers)=630 + 240 = 870....
thanks...
I did it using Bluej ....
class Divisors
{
public static void main(String args[])
{
int c=0;
int i =0;
for(i=1;i<=61;i++)
{
if(i%3 ==0 || i%5 ==0)
{
c=c+i;
}
}
System.out.println(c);
} }
The numbers that are divisible by 3 are multiples of three in the range 1 ≤ N ≤ 6 1 , thus, 3 , 6 , 9 , … 6 0 There are 2 0 such terms that we need to add.
The numbers that are divisible by 5 are multiples of five in the range 1 ≤ N ≤ 6 1 , thus, 5 , 1 0 , 1 5 … 6 0 . There are 1 2 such terms.
But, we overcount numbers that are divisible by both, and these are precisely the numbers divisible by 1 5 , like 1 5 , 3 0 , … 6 0 . There are 4 such terms.
Thus, we need to find the sum of these series. We observe that these are just arithmetic series. The sum of arithmetic series of the form a 1 + a 2 + ⋯ + a n is given by 2 n ( a 1 + a n )
Thus, we have to find
2 2 0 ( 3 + 6 0 ) + 2 1 2 ( 5 + 6 0 ) − 2 4 ( 1 5 + 6 0 ) which is 8 7 0
There are floor(61/3)=20, floor(61/5) = 12 and floor (61/(3 * 5))=4 numbers divisible by 3, 5, 15 respectively.
Now, sum of the numbers divisible by 3 is = (20/2)*(2 * 3 + (20-1) * 3) = 630
sum of the numbers divisible by 5 is = (12/2)*(2 * 5 + (12-1) * 5) = 390
sum of the numbers divisible by 15 is = (4/2)*(2 * 15 + (4-1) * 15) = 150.
So total sum of the numbers divisible by 3 or 5 = 630 + 390 - 150 = 870
Multiples of 3 : 3 , 6 , 9 , . . . , 5 4 , 5 7 , 6 0
Multiples of 5 : 5 , 1 0 , 1 5 , . . . , 5 0 , 5 5 , 6 0
Multiples of 1 5 : 1 5 , 3 0 , 4 5 , 6 0
Hence, sum of all integers N = ( 3 + 6 + 9 + . . . + 5 4 + 5 7 + 6 0 ) + ( 5 + 1 0 + 1 5 + . . . + 5 0 + 5 5 + 6 0 ) − ( 1 5 + 3 0 + 4 5 + 6 0 )
= 3 ( 1 + 2 + 3 + . . . + 1 8 + 1 9 + 2 0 ) + 5 ( 1 + 2 + 3 + . . . + 1 0 + 1 1 + 1 2 ) − 1 5 ( 1 + 2 + 3 + 4 )
= 3 × 2 2 0 × 2 1 + 5 × 2 1 2 × 1 3 − 1 5 × 2 4 × 5
= 3 × 2 1 0 + 5 × 7 8 − 1 5 × 1 0
= 6 3 0 + 3 9 0 − 1 5 0
= 8 7 0
using namespace std; main(){ int b,hasil=0; int batas=61; for(int i=1;i<b;i++){ if((i%3==0)||(i%5==0)){ hasil +=i; }} cout<<hasil; getch(); }
3 ---> 3, 6, 9, 12, 15, ... , 60 = 3/2 . 20 . 21 = 630 ; 5-----> 5,10,20,25,35,40,50,55 = 240. Thus, 630 + 240 = 870
sum(3+6+12+......+60)+ sum(5+10+15+......60)-sum(15+30+45+60)
Divisible by 3 are: 3, 6, 9, ..., 60.
Divisible by 5: 5, 10, 15, ..., 60.
Divisible by 3 & 5: 15, 30, 45, 60.
By P.I.E., we have that [Sum of divisible by 3 or 5] = [sum of divisible by 3] + [sum of divisible by 5] - [sum of divisible by 3 & 5] = 3(1+2+...+20)+5(1+2+...+12)-15(1+2+3+4)=870
by using the formula 1+2+...+n=n(n+1)/2.
public static calculateSum() {
int sum=0; for(int i=1;i<=61;i++) { if(i%3==0||i%5==0) sum=sum+i; } System.out.println(sum);
}
Problem Loading...
Note Loading...
Set Loading...
First find the sum of all numbers which are divisible by 3, and are less than 61. i.e. there are ⌊ 3 6 1 ⌋ = 2 0 numbers divisible by 3 and are less than 61.
So, their sum
S 1 = 3 + 6 + 9 + . . . . . . + ( 2 0 terms ) = 3 ( 1 + 2 + 3 + 4 + . . . . + 2 0 ) = 3 × 2 2 0 × 2 1 = 6 3 0
Now, the sum of all numbers which are divisible by 5, and are less than 61. i.e. there are ⌊ 5 6 1 ⌋ = 1 2 numbers divisible by 5 and are less than 61.
So, their sum
S 2 = 5 + 1 0 + 1 5 + . . . . . . + ( 1 2 terms ) = 5 ( 1 + 2 + 3 + 4 + . . . . + 1 2 ) = 5 × 2 1 2 × 1 3 = 3 9 0
But, there are some numbers which are divisible by both 3 and 5 and have been included twice. So, we have to subtract them once. The common multiples can be obtained by taking L C M ( 3 , 5 ) = 1 5 . Hence, there are ⌊ 1 5 6 1 ⌋ = 4 numbers which are divisible by both 3 and 5 and are less than 61.
Their sum
S 3 = 1 5 + 3 0 + . . . . . . + ( 4 terms ) = 1 5 ( 1 + 2 + 3 + 4 ) = 1 5 0
So, the final answer is
S = S 1 + S 2 − S 3 = 6 3 0 + 3 9 0 − 1 5 0 = 8 7 0
That's the answer!