algorithm - N th term of series:0,1,3,6,10,15,21, -


0,1,3,6,10,15,21,... each term gets incremented in order of natural numbers tried generate nth of series ended tle here's code

s=0 for(int i=1;i<=n;i++)     s=s+(i-1); 

can me better algorithm.

this series, gives n sum of natural number 0 n. there simple formula calculating (n * (n+1)) / 2.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -