![]() |
|
Think about Loose Coupling | |
PerlMonks |
Re^7: Algorithm for cancelling common factors between two lists of multiplicandsby sk (Curate) |
on Aug 11, 2005 at 08:50 UTC ( #482867=note: print w/replies, xml ) | Need Help?? |
Update:Added output and updated the list entries based on BrowserUk's final code example
Thanks for the detailed explanation! Sometimes i get very sloppy when I write. My apologies, i should not have used the word factorize instead i should have used the word 'cancel' out.. Actually I was thinking more in terms removing'like' elements. This is in reference to your code. In the code that I had, I was removing further cancelable terms Going back to your example
Here is a simple implementation of canceling out factorial terms without having to expand the factorials because of the fact
Now with the expanded list I would run the GCD program which cancels out even more terms like for example the number 11 cancels 56089 in the numerator and cancels 2398 in the denominator I hope it is clear now. The reason I was trying to factor down even further is to avoid computing at very high precision for numbers that are going to be canceled out anyways Has been a very interesting exercise so far!!! I will keep thinking about this problem as I am sure there should be a way to factor these numbers down further without going GCD route given they have such a nice pattern..after all they are just sequential products!
In Section
Seekers of Perl Wisdom
|
|