Graham's FunctionFinding Graham's Function Using Perl#1

The Challenge

Date: Wed, 11 Dec 2002 15:07:25 -0500
From: Mark Jason Dominus
Reply-To: perl-qotw-discuss@plover.com
To: perl-qotw@plover.com
Subject: Perl 'Expert' Quiz-of-the-Week #8

Graham's function (named for Ronald L. Graham, director of research at
AT&T Bell Labs) of a positive integer n is computed as follows: Find
an increasing sequence of integers a0, a1, ..., a_k such that

        1. a0 = n
        2. The product of the integers is a perfect square
        3. a_k is as small as possible.

Then G(n) = a_k.

...

Write a function, 'Graham', which, given a positive integer n, returns G(n)
Copyright © 2005 Shlomi Fish