in reply to Fraction Cancelation

Since Perl 6 has good handling of rational numbers, perhaps looking at its guts would help.

Using Perl 6 one could use the OP's arrays to do this:

#!/usr/bin/env perl6 my @a = <1 4 6 2 7 87 5 6 4 32>; my @b = <86 50 62 41 32>; my $a = [*] @a; my $b = [*] @b; say "Product of array \@a = $a"; say "Product of array \@b = $b"; # generate an arbitrary precision rational number: my $c = FatRat.new($a, $b); say "Real \$c: $c"; say "Rational \$c: { $c.numerator } / { $c.denominator }";

Output

Product of array @a = 112250880 Product of array @b = 349779200 Real $c: 0.3209193 Rational $c: 87696 / 273265