Thread: Calculating Factorial

  1. #1
    Registered User
    Join Date
    Jun 2008

    Calculating Factorial


    I want to write C++ program to calculate the factorial for numbers from 1 until 255, the problem is that no variable exist as far as I know that can handle the result for calculating 140! And greater “I am not sure about the number but it is stuck at some level”..

    Someone advise me to use this library “” to solve the issue but I couldn’t use the library as I am beginner in programming field..

    Can you advise me about a solution or how to use this library step by step ..

    -- Put in your mind that the result from the factorial will be added to a formula (i.e. I will add it or multiply it by another values, so the will program will calculate the factorial as a part of the complete formula “the big formula”). I am saying that to let you know that the array solution is not helpful in my case.

    Last edited by ice661666; 06-11-2008 at 08:08 PM.

  2. #2
    Weak. dra's Avatar
    Join Date
    Apr 2005
    I took a quick look at GMP and it seems like the right choice for you. Rather than using functions to perform your arithmetic (like you need to in C), the classes provided in the C++ wrapper overload operators such as + and - for you.

    have a look at the manual

  3. #3
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    London, UK
    There's really no other option than to use a third party library to store the results. Have a look at the manual that dra suggested and come back to us with any questions.

    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  4. #4
    Registered User
    Join Date
    Jun 2008
    Thanks Guys...

    which files i need to dlownload from

    My operating system is Win XP.
    I am using Microsoft Visual Studio 2005.

    After downloading what is the next step to embed the library in my program?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Segmentation fault using recursion to find factorial
    By kapok in forum C++ Programming
    Replies: 4
    Last Post: 02-23-2009, 11:10 AM
  2. Factorial
    By foxman in forum Contests Board
    Replies: 27
    Last Post: 07-11-2008, 06:59 PM
  3. Recursion
    By Lionmane in forum C Programming
    Replies: 11
    Last Post: 06-04-2005, 12:00 AM
  4. Basic Factorial from 1-10
    By AaA in forum C Programming
    Replies: 20
    Last Post: 05-28-2005, 07:39 AM
  5. factorial output
    By maloy in forum C Programming
    Replies: 1
    Last Post: 03-13-2002, 03:28 PM