1. Pick the first element of array a
2. Calcuate the GCD(a,b) or better yet
a = mod (a, gcd(a,b) and b =mod (a, gcd(b,b) (just divide elements by gcd, it should be an integer)
3. If anything is 1 pop it out of the list
4. Go through the list of elements for b with a again. Do this until all elements are scanned in b.
5. Take the second element in a and repeat the process.
Does this work?
I shall post the code if i get a chance to implement it
PS: This reminds of division in high school days ;)
|Replies are listed 'Best First'.|
Re^3: Algorithm for cancelling common factors between two lists of multiplicands
by BrowserUk (Pope) on Aug 08, 2005 at 20:50 UTC