How can I see the iterations described by Liu Daocheng of the self-taught IT network?

Source: Internet
Author: User
I saw Liu Daocheng, a self-taught IT network, talking about the iterations. how can I see it? the main reason is that there are too many nonsense videos there. The logic thinking is broken!
Who can tell me what iteration is? What is the difference between iteration and recursion?
Be sure to use the code to speak. The theory alone does not understand it!


Reply to discussion (solution)

Function iteration ($ n) {$ s = 0; for ($ I = 1; $ I <= $ n; $ I ++) $ s + = $ I; return $ s;} function recursion ($ n) {if ($ n> 1) return $ n + recursion ($ n-1); else return 1 ;}echo iteration (10 ); echo recursion (10);/* iteration: use the original value of the variable to calculate a new value of the variable. if recursion is self-called, iteration is A non-stop call B. there must be iterations in recursion, but not necessarily in iteration. most of them can be converted to each other. use iterations instead of recursion */

Function iteration ($ n) {$ s = 0; for ($ I = 1; $ I <= $ n; $ I ++) $ s + = $ I; return $ s;} function recursion ($ n) {if ($ n> 1) return $ n + recursion ($ n-1); else return 1 ;}echo iteration (10 ); echo recursion (10);/* iteration: use the original value of the variable to calculate a new value of the variable. if recursion is self-called, iteration is A non-stop call B. there must be iterations in recursion, but not necessarily in iteration. most of them can be converted to each other. use iterations instead of recursion */


Is accumulation an iteration?

Use the original value of the variable to calculate a new value of the variable.
Should it be difficult to narrow down the concept of geography to accumulate? Although accumulation is also one of them

Iteration is to update to another value based on the original value segment.

Recursion is a space for leeching, calling layer by layer, and returning layer by layer

Iteration is to update to another value based on the original value segment.

Recursion is a space for leeching, calling layer by layer, and returning layer by layer


This metaphor is quite simple!

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.