Original Post
I'm doing a research project for school which compares the binomial theorem to a particular method I thought up and checks the speed of generation of some parts of pascal's triangle. Unfortunately, the best division algorithm I could come up with was something like this:
//precondition: numerator can definitely be divided by
//denominator evenly
newnumber=denominator
quotient=1
While(newnumber!=numerator)
{
newnumber+=denominator
quotient++
}
This method works, but unfortunately it is very slow for small values for the denominator or large values of the numerator (I need to calculate up to 32! on my 550 mhz), and therefore unfairly stacks in favor my method (which uses division of small numbers). Is there ANY other algorithm I could use?. BTW I created a BIGNUM class, the class elements sort of look like this:
class NUMBER
{
NUMBER *next; //points to a sucessive digit (tens if this is
//the ones
int datum; //holds one digit of a number
};
class BIGNUM
{
NUMBER *head //keeps track of the memory address of the unit
// digit
};
As you can see, this further complicates the issue as I can't just do long division because the numerator and the denominator could both be numbers larger than 20 digits easily. Any ideas? I consider myself good at computer science, but this problem is beyond me. I am also open to completely redesigning the class if someone has a really good suggestion.
[edited by - uber_n00b on October 28, 2003 6:40:32 PM]