Python Forum
how to explain this function run?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to explain this function run?
#1
def tri_recursion(k):
  if(k>0):
    result = k+tri_recursion(k-1)
    print(result)
  else:
    result = 0
  return result

print("\n\nRecursion Example Results")
tri_recursion(6)
feel confused Huh
Reply
#2
What were you expecting? How does what you got not match what you were expecting?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
how many steps does it run?
what is the first step?

Thanks.
Reply
#4
Have you even run the program?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Please explain uncommon way of declaring and using variable [function.variable] esphi 4 2,342 Nov-07-2020, 08:59 AM
Last Post: buran
  could someone explain keywords, marks, and function DrKatherineThuyMiller 14 4,547 Jul-23-2020, 07:14 PM
Last Post: DrKatherineThuyMiller

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020