Monday, April 8, 2013

10783 - Odd Sum

Using the comments:

b=a+(n-1)d (arithmetic series)
sn=n/2[2a + (n-1)d] 

sum = (n * (2*a + (n-1)*d))/2; had a wrong answer when I tried to divide n/2 first. if n=1 then n/2 = 0 (flooring). 


No comments:

Post a Comment