Find all integers from 1 to n, and

As an example loop computer programming language, find and accumulate virtually all mainstream programming language, understanding and solving the accumulation process to grasp the essence of the loop has an important role. The most common examples are seeking and seeking accumulation and 1 to 100.

int Sum(int n)
{
	int i=1,sum=0;
 	while(i<=n)
 	{
  		sum=sum+i;
  		i++;
 	}
 	return sum;
}
Published 44 original articles · won praise 35 · views 808

Guess you like

Origin blog.csdn.net/huangziguang/article/details/104447568