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

ความคิดเห็น • 55

  • @pichonPoP
    @pichonPoP ปีที่แล้ว +4

    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.

  • @solidsnack9950
    @solidsnack9950 ปีที่แล้ว +1

    Thanks for improving my problem.

  • @markdiaz4129
    @markdiaz4129 4 ปีที่แล้ว +10

    Awesome tutorial. This was one of the problems my professor asked and you explained it perfectly. Thanks a lot

  • @yentarachangethelife3897
    @yentarachangethelife3897 3 ปีที่แล้ว +2

    My dear Learning Lad❤❤❤

  • @anamggss
    @anamggss ปีที่แล้ว +2

    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

  • @ilhan537
    @ilhan537 ปีที่แล้ว +1

    Thanks You have explained Correctly.

  • @khilesh1815
    @khilesh1815 2 ปีที่แล้ว +1

    Thanks bro your video really helped me to make my first factorial program

  • @soumyasingh6142
    @soumyasingh6142 2 ปีที่แล้ว +1

    Thank you sir, it helped!

  • @solidsnack9950
    @solidsnack9950 ปีที่แล้ว +2

    What can I do for larger numbers? I used long long but it didn't work.

  • @Oki.hou0929
    @Oki.hou0929 ปีที่แล้ว

    What about factorials in permutations?

  • @sukhandeepkaur4552
    @sukhandeepkaur4552 ปีที่แล้ว +1

    Amazing video ever 🎉 first time I watch your video sir it’s amazing

  • @aueputin1385
    @aueputin1385 ปีที่แล้ว +1

    incredible explanation

  • @Ld06
    @Ld06 2 ปีที่แล้ว +1

    Thank you 💞💞

  • @waridkhan971
    @waridkhan971 3 ปีที่แล้ว

    hi sir. plz make video on program description with shamil's memory table.

  • @eriksaucedo4382
    @eriksaucedo4382 3 ปีที่แล้ว

    i cant get it to work with large numbers like 20 how do i do that please help

  • @angelhabiby8894
    @angelhabiby8894 2 หลายเดือนก่อน +1

    more perfect an easier than the rest of the tutorials

  • @thecriminals6949
    @thecriminals6949 ปีที่แล้ว +1

    thanks sir

  • @RayyanKhan-nv5il
    @RayyanKhan-nv5il 20 วันที่ผ่านมา +1

    Superb

  • @niveshgaming2528
    @niveshgaming2528 6 หลายเดือนก่อน +1

    which app do you use to run the code

  • @craftsworld3237
    @craftsworld3237 2 ปีที่แล้ว +2

    Where do you get this vs code theme?

  • @user-zy3hx8yl3r
    @user-zy3hx8yl3r 3 ปีที่แล้ว +1

    I like his accent

  • @callme_SRK
    @callme_SRK ปีที่แล้ว

    Why fact=1 what if we give 2 3 etc...

  • @dukeofmilan2814
    @dukeofmilan2814 3 ปีที่แล้ว +1

    Where is output???

  • @rollno14abhisheksharma52
    @rollno14abhisheksharma52 2 ปีที่แล้ว

    But it find fac of 45 how it will display

  • @dawitejigu
    @dawitejigu 3 ปีที่แล้ว +2

    why factorial = 1 in declaraton please

    • @ExampleProgram
      @ExampleProgram  3 ปีที่แล้ว +4

      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.

  • @M_Hamxa
    @M_Hamxa 3 หลายเดือนก่อน +1

    what his compiler name ??

  • @kingteshome5034
    @kingteshome5034 2 ปีที่แล้ว

    What is the name of the software or apk

  • @MillieLilth
    @MillieLilth 3 ปีที่แล้ว

    I cant see nothing

  • @vaibhavpratap1041
    @vaibhavpratap1041 3 ปีที่แล้ว +1

    Where are you from?

  • @enesytm8867
    @enesytm8867 4 ปีที่แล้ว +4

    bruh it ain't work

    • @hypermeero4782
      @hypermeero4782 3 ปีที่แล้ว +1

      for(int counter = number ; counter > 0 ; --counter)
      his for loop was wrong

  • @Zomatsu143
    @Zomatsu143 7 หลายเดือนก่อน

    This isn't a while loop thou

  • @salarramejo-tg3hl
    @salarramejo-tg3hl ปีที่แล้ว +1

    Hello sir

  • @gulbadanofficial3135
    @gulbadanofficial3135 2 ปีที่แล้ว +2

    I got nothing

  • @blabruh9059
    @blabruh9059 2 ปีที่แล้ว

    bruh it isn't working. lol