Calculating Factorial

This is a discussion on Calculating Factorial within the C++ Programming forums, part of the General Programming Boards category; Hi, I want to write C++ program to calculate the factorial for numbers from 1 until 255, the problem is ...

  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    2

    Calculating Factorial

    Hi,

    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 “http://gmplib.org/” 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.

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

  2. #2
    dra
    dra is offline
    Weak. dra's Avatar
    Join Date
    Apr 2005
    Posts
    166
    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
    http://gmplib.org/manual/C_002b_002b...lass-Interface

  3. #3
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    894
    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.

    QuantumPete
    "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
    Posts
    2
    Thanks Guys...

    which files i need to dlownload from http://gmplib.org/?

    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, 07:59 PM
  3. Recursion
    By Lionmane in forum C Programming
    Replies: 11
    Last Post: 06-04-2005, 01:00 AM
  4. Basic Factorial from 1-10
    By AaA in forum C Programming
    Replies: 20
    Last Post: 05-28-2005, 08:39 AM
  5. factorial output
    By maloy in forum C Programming
    Replies: 1
    Last Post: 03-13-2002, 03:28 PM

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