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
Post a Comment