Jump to content

cococidial

Members
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

0 Neutral

About cococidial

  • Rank
    Newbie
  1. cococidial

    recursion example in python for loops

    Thanks, that makes sense finally.
  2. cococidial

    recursion example in python for loops

    I don't understand how this code from the python for loops example gets the answer. 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) The answer: 1, 3, 6, 10, 15, 21. I'm still very new at python. I thought the way the code would work is: result = 6 + (6-1) = 11 With the presumption that k=6. I've clearly got it wrong and would be gratefully for someone to explain how the code works.
×