Like Tree8Likes
  • 7 Post By Lesshardtofind
  • 1 Post By phantomotap

[ c++] factorial anynumber By me

This is a discussion on [ c++] factorial anynumber By me within the C++ Programming forums, part of the General Programming Boards category; [ c++] factorial anynumber By me Code: #include <iostream> #include <iomanip> #include <cmath> using namespace std; int factorial(int a) { ...

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    3

    [ c++] factorial anynumber By me

    [ c++] factorial anynumber By me

    Code:
    #include <iostream>
    #include <iomanip>
    #include <cmath>
    using namespace std;
    
    int factorial(int a)
    {
         int c=a;
         for (int n=a-1; n>=1; n--) 
         {
             c*=n;
         }
         return c;
    }
    
    
    int main()
    {
    
     int Fac,r;
    
    cout<< " factorial of  ";
    cin>>Fac;
    
    r=factorial(Fac);
    cout<<r;
    
            cout <<endl;
        system("pause");
        return 0;
    }

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,344
    O_o

    What is the purpose of these posts?

    Soma

  3. #3
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    407
    I think he's really excited about programming.. Either that or salem finally made his 32,767th post and rolled over into a newbie with an appended prefix.

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    I would fix the indentation and the OS specific system call, but other than that it seems fine.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,344
    salem finally made his 32,767th post and rolled over into a newbie with an appended prefix.
    I choose to believe that this is exactly what happened.

    Soma
    thames likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. factorial value
    By joybanerjee39 in forum C Programming
    Replies: 4
    Last Post: 11-14-2011, 11:40 AM
  2. Factorial
    By SpockRox08 in forum C++ Programming
    Replies: 7
    Last Post: 10-24-2010, 02:07 AM
  3. Factorial 100!
    By ganesh bala in forum C Programming
    Replies: 5
    Last Post: 06-24-2009, 01:34 AM
  4. FACTORIAL. Can you hel me about this
    By Melody in forum C Programming
    Replies: 57
    Last Post: 11-20-2007, 07:32 AM
  5. Factorial
    By DonW in forum C Programming
    Replies: 10
    Last Post: 09-19-2004, 04:53 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21