#Mastery21 use of recursion

You use recursion in functions for repetitive algorthms. Basically griting a function inside itself for a sort of loop, making your code smaller and cleaner.

this program is grat example, I have 2 functions and they repeat inside each other, I could have made different functions but they would have recursion in that way. 
#Mastery21 use of recursion

#Mastery21 use of recursion
 my WSQ12 is also a great example of recursion.
in this case the program uses de function gcd to determine the greatest comon divisor, and ans is the gratest common divisor itself, in case that the numbers given by the user are not the same (not x==y), the fuction will call itself but with some changes:

else:
if(x>y):
ans=gcd((xy),y)
else:
ans=gcd(x,(yx))
return ans

other examples of recución are: palindromesstandard deviation

CC BY 4.0 #Mastery21 use of recursion by Eduardo Merino is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.