C++ Program to find the Factorial of a Number using For Loop
ฝัง
- เผยแพร่เมื่อ 9 ธ.ค. 2019
- In this video you will learn to write a C++ Program to find the factorial of a number using For Loop ( Iterative Method ).
The factorial of a positive integer n, which is denoted as n!, is the product of all positive integers less than or equal to n.
That is n! = n * (n-1)*(n-2)*....*3*2*1
So 4! = 4 * 3 * 2 * 1 which is equal to 24.
Factorial for the numbers 0 and 1 is 1. That is 0! = 1 and 1! = 1. For negative numbers factorial value doesn't exists.
C++ Program to Find the Factorial of a number using Recursion ( Recursive Method )
• C++ Program to find th...
Get the Source Code of this tutorial at
www.ExampleProgram.com
our Social Media Pages
/ exampleprogram
/ exampleprogram
/ example_program
#CppProgramming #ExampleProgram
This platform shows me this video today, and last week I was struggling to do this. Finally, could do, but I'm glad to see another solution tiny different from mine.
glad my video helped you :)
Thanks for improving my problem.
Awesome tutorial. This was one of the problems my professor asked and you explained it perfectly. Thanks a lot
You are welcome!
My dear Learning Lad❤❤❤
Great tutorial, I'm confused about one thing though. In all of the examples I've seen including yours the initial value of (counter = number). And it always ends up being the correct answer.
However when I try this, it will instead give the result of the factorial * the original number, so I have to put (counter = number -1) to get the correct answer. Which makes sense since without the -1 it would essentially be multiplying num with itself first. Which is why it's so confusing on how this is working on your and other people's ends
Thanks You have explained Correctly.
You are welcome
Thanks bro your video really helped me to make my first factorial program
Glad I could help
Thank you sir, it helped!
You're welcome!
What can I do for larger numbers? I used long long but it didn't work.
What about factorials in permutations?
Amazing video ever 🎉 first time I watch your video sir it’s amazing
Thank you :)
incredible explanation
Glad you think so!
Thank you 💞💞
Most welcome
hi sir. plz make video on program description with shamil's memory table.
i cant get it to work with large numbers like 20 how do i do that please help
more perfect an easier than the rest of the tutorials
Thank you
thanks sir
most welcome :)
Superb
Thanks 🤗
which app do you use to run the code
Vs code
Where do you get this vs code theme?
available by default
Vs code
I like his accent
Why fact=1 what if we give 2 3 etc...
Where is output???
But it find fac of 45 how it will display
why factorial = 1 in declaraton please
Sorry for late reply.
For numbers 0 and 1 the factorial value is 1
Initialising factorial with 1 will work nicely with the logic used in this program.
what his compiler name ??
gcc
What is the name of the software or apk
Vs code
I cant see nothing
Where are you from?
Karnataka
bruh it ain't work
for(int counter = number ; counter > 0 ; --counter)
his for loop was wrong
This isn't a while loop thou
Hello sir
Hello
I got nothing
Check your code
bruh it isn't working. lol