Thread: [ c++] factorial anynumber By me

  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
    5,108
    O_o

    What is the purpose of these posts?

    Soma

  3. #3
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    428
    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.
    Virtual reality hello world http://www.rodneybrothers.com/vr/vrh...rld/index.html in html and javascript.
    Viewable with dodocase, google cardboard, OR, and other compatible VR gear.

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    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
    5,108
    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

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, 12:40 PM
  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, 08:32 AM
  5. Factorial
    By DonW in forum C Programming
    Replies: 10
    Last Post: 09-19-2004, 04:53 PM