ScratchData LogoScratchData
Back to crkcity's profile

boring lesson on triple recursion

CRcrkcity•Created February 2, 2023
boring lesson on triple recursion
2
1
34 views
View on Scratch

Instructions

To better understand multiple recursion. Recursion keeps "stacks" of numbers, in this case 5, 4, 3, 2, but if any of those doesn't meet this case's criteria, If n > 2, then the number in the stack is knocked off the stack. The stack is like a list. The function which I named "subtract" makes "recursive calls to the stack." This might help us understand how recursion can elegantly make trees and fractals.

Description

The "add n to list of ns" is only to show us what is happening. That list is not necessary. The recursion keeps it's own internal list called a "stack." The recursive function "subtract" starts with n = 5 if n > 2 set n to n - 1 --> 5, 4, 3, 2 (numbers in a stack) since 2 is not > 2, code knocks "2" off the stack but then goes to set n to n - 2 starting with "3" (the number at top of stack) so 3 - 2 is 1 ... then goes to set n to n - 3 I based this on a u tube tutorial (although that used C++): youtube ?v=0nKIr3kAt-k

Project Details

Project ID797882588
CreatedFebruary 2, 2023
Last ModifiedFebruary 5, 2023
SharedFebruary 5, 2023
Visibilityvisible
CommentsAllowed