Jeff Aa wrote at Thu, 26 Sep 2002 10:52:46 +0200:
> I need to determine the highest common factor for a series of integers.
> I have scribed an initial stab included below - does anyone have a
> better HCF implementation, or any improvements to suggest?
Well, here's a funny way:
use Quantum::Superpositions;
use List::Util qw/max/;
sub factors {
my ($n) = @_;
my $q = $n / any(1..$n);
return any eigenstates($q == any(1 .. $n));
}
sub gcf {
max eigenstates(all(factors(shift),factors(shift))), "\n";
}
print gcf(@ARGV);
Of course, don't use it in production unless you
really have a quantum computer.
Greetings,
Janek
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]