Reasoning is a kind of logical thinking, a methodology, inductive inference is from the personality derivation to the general process, and deductive reasoning from the common to the personality of the process of recursion. The generality and particularity of things is the base point of the reasoning method, and the following example is a simple way to understand how the inductive reasoning from the special ascent to the general.
The mathematical induction method first proves that the proposition of starting value is established, then proves that the process from N value to n+1 is effective, and then arbitrary value is recursive.
Prove the factorial n of the natural number n! Steps:
Known n!=n* (N-1) * (N-2) * (N-3) *...*2*1 when N=1 n!=1, set when R (N) =n!, prove R (n+1) = (n+1)! established.
Proof process: R (n+1) = (n+1)! = (n+1) * (n) * (N-1) *...*2*1= (n+1) *n!= (n+1) *r (n) = (n+1)!
Obviously recursion is also using the idea of mathematical induction to construct functions, for factorial n! The recursive function is implemented as follows:
factorial (int N) {
if (N ==1) return 1; /* Exit */
return N * factorial (N-1)/* recursive */
}
Recursive function implies that the recursive idea is connected with the mathematical inductive method. The recursive main function is defined as follows:
Do not carry out, to (n/b) respectively in the integration power, the upper rounding, the next rounding situation.
Mathematical induction and recursion in the introduction of algorithms