Комментарии:
N* factorial (n-1)
ОтветитьThe way you teach is really amazing and too good keep it up!!!
ОтветитьThanks, a great explanation especially the last part when you detailed about factorial(1)=1 and how the program calculates from last to top👏👏
ОтветитьThanks!
ОтветитьIncredibly helpful but you omitted something relevant to this problem. The concept of a 0! (0 factorial) exists and by definition, 0! = 1
Ответитьgood stuff thanks.
ОтветитьI'm confused how is it possible for it to ever execute the else statement when the if statement is executed when it reaches 1? How is that possible?
ОтветитьThis is a great tutorial.
For a small adjustment, shouldn’t the base case technically be:
if (n==1 || n == 0)
{
return 1;
}
Since 0! Is also 1?
Love your guidance brother👌👌.
Ответитьyou are good
Ответить// Iterative factorial method.
public class FactorialCalculator
{
// recursive declaration of method factorial
public long factorial( long number )
{
long result = 1;
// iterative declaration of method factorial
for ( long i = number; i >= 1; i-- )
result *= i;
return result;
} // end method factorial
// output factorials for values 0-10
public void displayFactorials()
{
// calculate the factorials of 0 through 10
for ( int counter = 0; counter <= 10; counter++ )
System.out.printf( "%d! = %d\n", counter, factorial( counter ) );
} // end method displayFactorials
} // end class FactorialCalculator
(Using the FactorialCalculator): Modify the program to allow input on what factorial is required instead of
10.
can u please do it
This Guy is the God of Teaching !! Damn finally understood what this Recursion means. Thank You Alex !
ОтветитьThis really helps Alex, Thank You!!
Ответить!0 is 1 so the base case that should return 1 is n == 0. Everything else is perfect for every input. Otherwise if you put a 0 for n the code keeps running.
ОтветитьIs this code works for 13 factorial?
ОтветитьCan we solve it using a void return type instead of int or long, if not then why not? I'm really confused can't solve it using the void return type
ОтветитьLOL。。I FINALLY UNDERSTOOD THE RECURSION. THANKS BRO
Ответитьamazing
ОтветитьYeah Now it is clear
Thanks a lot 🤺
Great explanation but you forgot to keep in mind that 0! is equal to 1. Super easy fix however by just updating your base case to n == 0.
ОтветитьI love this so much <3
ОтветитьGood explanation. But there is a bug in this code. What would be the value of factorial(0). I think you have not consider it. If you give an input as 0, error will be thrown at run time.
ОтветитьI find it interesting how it knows to sort of work backwards once it finally finds out what 1 is instead of just getting to 1 and stopping but it also knows to not go through the loop again.
Ответить10/10 thank you
ОтветитьSomething so easy, but very well explained! Thanks a lot
ОтветитьI am so glad to have u here 😇. Thank u so much for everything
Ответить"Good luck in your classes"
Man you're better than my lecturer ilysm I learn a lot from you
Hi! Could you plss make a vedio that has all the methods in one program like constructor, inheritence, return,(by calling them from one class to another class)....... It will help us.
But your explanation is perfect👍👍😊😊
How do I replace line 7 with a scanner?
Need help asap!
Wow thanks so much friend!!
Ответитьis it linear recursion? or what kind of recursion is this
ОтветитьThank you
You are great teacher 👌
You explanation is exactly what I needed to understand what the _ this code was doing.
Ответитьwhy do I get a negative value when i input 17 factorial?
ОтветитьThank you soo much
Ответитьexcellent explanation!!!!!!!!!!
Ответитьkosom slim
ОтветитьThanks! :)
ОтветитьThis reminds me of the Fibonacci sequence formulae
ОтветитьAlex, as the factorial gets each result of each recursion step, where is It being stored? You don’t seem to store each iteration result in a variable. I just see the final 120.
ОтветитьAmazing clarification !!!!!!!!!
Hey! Alex , I am in beginner in java . Have to learn java because of selenium tool. After seen your video really want to concern what is the easy way to learn java concepts?
Please advise.....
Bruhhh 😭
ОтветитьBeautiful. I like how he uses the print statements at the end. It helps to clarify what's going on step by step. Simply perfect.
ОтветитьVery Good
Ответитьyour awesome. thnx
ОтветитьGood Explain: I understand in the last part of the video and how exactly it,s work. Thanks
ОтветитьWow fam these are the best videos on recursion I've seen!
ОтветитьGreat work here Alex!
ОтветитьOMG. Thanks, Alex! Finally understood it! :O
Ответить