C++ Program to find the Factorial of a Number using For Loop

Поділитися
Вставка
  • Опубліковано 18 жов 2024
  • 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.ExamplePro...
    our Social Media Pages
    / exampleprogram
    / exampleprogram
    / example_program
    #CppProgramming #ExampleProgram

КОМЕНТАРІ • 57

  • @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 2 роки тому +2

    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

  • @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

  • @sukhandeepkaur4552
    @sukhandeepkaur4552 Рік тому +1

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

  • @Shalini45006
    @Shalini45006 Місяць тому

    What input should I use for zero?

  • @aueputin1385
    @aueputin1385 Рік тому +1

    incredible explanation

  • @yentarachangethelife3897
    @yentarachangethelife3897 3 роки тому +2

    My dear Learning Lad❤❤❤

  • @solidsnack9950
    @solidsnack9950 2 роки тому +2

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

  • @niveshgaming2528
    @niveshgaming2528 10 місяців тому +1

    which app do you use to run the code

  • @soumyasingh6142
    @soumyasingh6142 2 роки тому +1

    Thank you sir, it helped!

  • @Ld06
    @Ld06 2 роки тому +1

    Thank you 💞💞

  • @angelhabiby8894
    @angelhabiby8894 6 місяців тому +1

    more perfect an easier than the rest of the tutorials

  • @RayyanKhan-nv5il
    @RayyanKhan-nv5il 3 місяці тому +1

    Superb

  • @Oki.hou0929
    @Oki.hou0929 Рік тому

    What about factorials in permutations?

  • @thecriminals6949
    @thecriminals6949 Рік тому +1

    thanks sir

  • @craftsworld3237
    @craftsworld3237 2 роки тому +2

    Where do you get this vs code theme?

  • @M_Hamxa
    @M_Hamxa 6 місяців тому +1

    what his compiler name ??

  • @eriksaucedo4382
    @eriksaucedo4382 3 роки тому

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

  • @waridkhan971
    @waridkhan971 3 роки тому

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

  • @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.

  • @ПользовательБезфамилии-к5ю

    I like his accent

  • @callme_SRK
    @callme_SRK 2 роки тому

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

  • @dukeofmilan2814
    @dukeofmilan2814 3 роки тому +1

    Where is output???

  • @salarramejo-tg3hl
    @salarramejo-tg3hl Рік тому +1

    Hello sir

  • @vaibhavpratap1041
    @vaibhavpratap1041 3 роки тому +1

    Where are you from?

  • @rollno14abhisheksharma52
    @rollno14abhisheksharma52 2 роки тому

    But it find fac of 45 how it will display

  • @enesytm8867
    @enesytm8867 4 роки тому +4

    bruh it ain't work

    • @hypermeero4782
      @hypermeero4782 4 роки тому +1

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

  • @Zomatsu143
    @Zomatsu143 11 місяців тому

    This isn't a while loop thou

  • @kingteshome5034
    @kingteshome5034 3 роки тому

    What is the name of the software or apk

  • @gulbadanofficial3135
    @gulbadanofficial3135 3 роки тому +2

    I got nothing

  • @MillieLilth
    @MillieLilth 4 роки тому

    I cant see nothing

  • @AstralLaVista
    @AstralLaVista 13 днів тому

    I am sick of people using imaginary numbers in these examples, im a noob use actual number not m

  • @blabruh9059
    @blabruh9059 2 роки тому

    bruh it isn't working. lol