Mathematical induction and recursion in the introduction of algorithms

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.