Review recursion

来源:互联网 发布:大数据商业模式大赛 编辑:程序博客网 时间:2024/06/03 00:33

 Today, encounter an recursion problem to caculate the sum value of 1+2+3...+100.

 

So simple question, eventhough I can finish the program. However, I am not very clear about the concept of recursion. Record it now:

 

 

my code:

 

In fact,

 

the concept of recursion is a method of defining functions in which the function being defined is applied within its own definition.

 

such as following function:

 

if n =1,  fun(n) = 1;   if n > 1, fun(n)=fun(n-1).