Комментарии:
can u recommend the books about the iteration
ОтветитьMissed your sound❤
ОтветитьThank you! very clear.
ОтветитьWho is this Teacher?
ОтветитьChaos
ОтветитьThank you sir!
Ответитьso basically (i think, idk cuz I'm just watching this video for fun, i dunno much about coding so correct me if I'm wrong)
for 0, we specify that if product = 0 or less, then return product = 1 since a 0 in this formula would mean 0(0+1) which is 0x1=0; what's happening is basically we take an integer (integers start from 0 unlike counting numbers that start from 1) and we put it in the formula 1(i+1) where i is the integer and the 1 outside of the parenthesis is the previous product/factorial since the product of 0 factorial is 1, we start with 1; as it iterates, the previous factorial product becomes the new product outside of the parenthesis we're trying to find so we continue doing this for the number of times we want a factorial for so 3! would be 6 because 1(0+1) = 1, 1(1+1) = 2, 2(2+1) = 6 so the to calculate the factorial we could also do:
def factorial(number):
if number <= 1:
return 1
else:
product = 1
for i in range(number):
product = product * (i+1)
return product
Thanks a ton Khan Academy. Idk why your videos don't get much views but your quality of teaching is remarkable! This is much better than the colleges/universities, that's why Elon Musk us with you guys😉
ОтветитьVeeeryy cool job man, big thanks to you✌️
Ответитьnot the comparison i expected ...
Ответитьwhich function is faster?
Ответитьrecursion is a billion times better than iteration tbh
ОтветитьBoom boom! Why is it so cutely explained!
ОтветитьI love the concept of Programming.
But I really hate the method my college book is explaining this.
Thank you Khan Academy!!!
Thanks god you're here.
Ответитьnote, that i + i should be i + 1? yes?
ОтветитьWhat does return do ?
Ответитьhey tech me if we put njmber=1 in if statement so ans is 1 how
Ответитьthe way you write it and show it here was enlightening for me
ОтветитьMust I always return 1
ОтветитьVery well explanation. So the program stacks the numbers n in memory then go back and solve each multiplication.
Ответитьthanks a lot
ОтветитьAbsolutely wonderful explanation of recursion. Well done!
ОтветитьThank you.
ОтветитьI have to admit, almost went to another video after hearing a mistake in the "iterative" pronunciation within the very first verbal audible of this video.
ОтветитьJust had one of those "Oooooooh" moments. Thanks Khan!
ОтветитьThis video doesn't provide any comparison like the title says. It's more of a walkthrough of an iterative and recursive example.
Ответитьyou can't explain recursions with functions in 2 minutes...
Ответитьit works this way: the function is still running while it calls the next function, so it builds up a stack of function calls (thus: call stack), then when it reached the base case, it returns a value, then the above returns, etc. etc. until the call stack has been reduced back to the original function call, which then returns the result, done. the variable number is NOT the same for all the function calls, each function call has its own variables.
ОтветитьI would never guess recursion would ever work because it APPEARS as if you are redefining the value of the variable "number" and returning a result every time the function recurs. The thing that needs explaining for me is how Python knows to remember each of the returned results for each recurring function call.
ОтветитьSal, watching this playlist makes me want to switch my major to CS :(:(:(
ОтветитьYOU'RE AWESOME, THANKS!!!
Ответить@radiator0505 I think it has to do with the definition of a factorial. It works fine when the numbers are decreasing, but the definition of a factorial given a negative number is different (since the numbers are increasing each time rather than decreasing).. this results in a divide-by-zero error when you get to 1. Why the program returns 1 I am not sure.
ОтветитьRecursion blows my mind.
Ответитьpython is the shit!
ОтветитьI love this guy
Ответитьsecond. lol
Ответить