Tag: equals the essential loop 10 s function recursive self function return
There are 200 of peaches in the park. Monkeys eat 10 a day, pick out two bad throw away, ask 6 days after the number of peaches remaining
/*var SL = 200;
for (Var i=0;i<6;i++)
{
SL = sl-12;
}
Alert (SL); */
The park has a bunch of peaches, the monkeys eat half a day, pick out a bad throw away, the 6th day when found to have 1 peaches, asked how many peaches
/*var SL = 1;
Number of the previous day = (number of current days + 1) * *;
for (Var i=0;i<6;i++)
{
SL = (sl+1) * *;
}
Alert (SL); */
Use the function to find
function function: Returns the number of peaches in the nth day
function self-Tune yourself
var sl;
function Shuliang (n)
{
When n equals 6 peach number is 1
if (n==6)
{
SL = 1;
}
Else
{
Find the number of the day
The number of the day = (number of next day + 1) * *;
SL = (Shuliang (n+1) +1) * *;
}
return SL; Returns the number of the day
}
Alert (Shuliang (0));
/*
Shuliang (0)
{
SL = (94+1) * *; Stuck
}
*/
The essence of recursion is to self-tune itself and can be seen as a nested loop of functions.
JS function recursion