Here is the formula i'm suppose to use:

i'm suppose to to write a complete program with a function using two parameters to calculate:

x(!)^n, where x(!)^n = x!! ... ! use BigInts For the calculations
                                  -----
                                   n times

this wis what I have, i don't think it's right, if you can tell me what is wrong, and correct it, i'd greatly appreciate it.

#include <iostream>
#include <cmath>
#include "bigint.h" //uses a class that is specified in my header file
                        //along with bigint.cpp
using namespace std;

BigInt Factorial(int num);

int main()
{
    int num;
    int power;
    int current = 0;
    cout << "Enter A Number: ";
    cin >> num;
    cout << "Enter A Power: ";
    cin >> power;
    while(current <= num)
    {
        cout << current << "! = " << Factorial(pow(current,power)) << endl;
        current += 1;
    }   
    return 0;
}

BigInt Factorial(int num)
{
    BigInt product = 1;
    int count = 0;

    while(count < num)
    {
        count += 1;
        product *= count;
    }
    return product;
}

Edited 3 Years Ago by Dani: Formatting fixed

does anyone have any ideas if this is correct or not?

>x(!)^n
>Factorial(pow(current,power))
Either your mathematical notation is wrong, or your code is. And the parens are mildly confusing, can you be more specific as to their purpose?

Thanks i've got it, it works fine, thanks for your help

>x(!)^n
>Factorial(pow(current,power))
Either your mathematical notation is wrong, or your code is. And the parens are mildly confusing, can you be more specific as to their purpose?

Very nice post!I'm newbie in your forum and i saw this post, because i've found lot's of problems about compute big factorial numbers in my application.This application based on an image processing algorithm .That's the main reason which i want to compute big factorial numbers.Could you help me???I would like to find the class bigInt which someone wrote before.Plz help me it's very important for me thanks a lot...

Comments
Check thread dates before posting - you're 2 years too late

I have an algorithm for calculating big factorials, I know you wanted it in year 2007, but if it will still help you please contact me .

This article has been dead for over six months. Start a new discussion instead.