This was part of my assignment, a small function. Book asks what the output is, if N=1. I simply can't wrap my head around, why the function counts down after reaching N<3, when it adds 1 to N
Don't know if this is homework help, or just help, as the assignment has been submitted.
I added the silly comments, just to see where I'm at.
Output is:
Don't know if this is homework help, or just help, as the assignment has been submitted.
I added the silly comments, just to see where I'm at.
Code:
def F1(N):
print(N, "First N")
if (N < 3):
print(N, "goin' in first time..")
F1(N + 1) #Prints N+1 = 2
print(N, "Last N")
F1(1)
Code:
1 First N
1 goin' in first time..
2 First N
2 goin' in first time..
3 First N
3 Last N
2 Last N
1 Last N