My programing World
A collection of programs and interview questions
Monday, December 30, 2013
Nth term in triangular number series
1 3 6 10 15 ......... This is tirangluar number series.
The nth term of triangular series is i*(i+1)/2.
If sum S is given then to program to find the nth term is
sum = 1;
n=1;
while(sum<=S)
{
next = ++n;
sum = sum + next;
}
So we get
value of N.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment