“I bought this guide a few days ago to prepare for my interview with Oracle. Many of the questions they asked me were from this guide. I found this book absolutely great!”
sum up 1 and 999, 2 and 998 3 and 997 etc. till 499 and 501 that sum is 1000×499 + 500 + 1000 (original 1000) and total is 500,500 Any objections? so I think hottypete is correct.
sum=n/2*( a+l)
where
n= number of terms,= 1000 in this case
a= first term, 1 in this case
l=last term l= 1000 in this case
after calculation it comes out to be 5050
In general the sum of numbers from 1 to n is given by: n*(n+1)/2
Regards,
Oliviu
Depends what NUMBER means here:
If means integer, that’s 100*(100+1)/2=5050;
If not, that’s infinity.
Integers from 1 to 1000 = 500,500
sum up 1 and 999, 2 and 998 3 and 997 etc. till 499 and 501 that sum is 1000×499 + 500 + 1000 (original 1000) and total is 500,500
Any objections? so I think hottypete is correct.
xianfeng is correct, too, except he used 100 instead of 1000.
1000 * (1000 + 1) / 2 = 500,500
So everybody’s right!!!
A mathematically sound answer should be:
1 + 1000 (= 1001)
+ 2 + 999 (= 1001)
+ 3 + 998 (= 1001)
.
.
.
+ 500 + 501 (= 1001)
= 500 * 1001 = 500500
An easier way to remember it might be “times a half, plus a half”, which is essentially what that calculation reduces to:
(n(n+1))/2 = n*(n/2) + n/2
Answer depends on the discreteness of the interval between the two numbers and as such can only be specified using an interval.
For natural numbers use Gauss’s theorem.
for any arithmetic progression
sum=n/2*( a+l)
where
n= number of terms,= 1000 in this case
a= first term, 1 in this case
l=last term l= 1000 in this case
after calculation it comes out to be 5050
jus a simple techniq.sum of ‘n’ natural numbers is n(n+1)/2..n here n is 1000..so simple na
Leave an Answer/Comment