Need:
Output some regular data: [0,1,1,2,3,5,8,13,21,34 ...]
See above need seems to have some rules, yes, is familiar with the Gustav that Wave, n= (n-1) + (n-2) such as 13=8+5;
The recursive principle is used to:
def func (ARG1,ARG2):
if arg1 = = 0:
Print Arg1,arg2
Arg3 = arg1 + arg2
Print Arg3
If Arg3 > 2046:
Return '
Func (ARG2,ARG3)
Func (0,1)
The function calls the function itself in the function to achieve recursion.
Note: The current return on return stops the function operation, but the return value should be returned to the last call, since the initiating function is the bottom function operation, so, the last function should be returned.
Such as:
1 deffunc (ARG1,ARG2):2 ifArg1 = =0:3 Pass4Arg3 = Arg1 +arg25 6 ifArg3 > 2046:7 returnArg38 returnfunc (ARG2,ARG3)9 Ten PrintFunc (0,1)
Results: 2584 returned ARG3
Python_ recursion principle