re: Compute Smart, Not Hard VIEW POST

re: 1994 is 92 * 22, so I’d guess no, it is not :) You should probably explicitly state the goal is to find all possible Francescos, but still, the br...

(I don't want to give away the game ;)...)

1988 is 32 * 82, and that's it.

use warnings;
use strict;

for my $born (1800 .. 2005) {
    my $prod = 1;
    $prod *= $_ for split //, $born;
    my $n = sqrt $prod;
    next unless $n == int $n;

    printf "%d %d\n", $born, $born + $n if $born + $n > 2005

Is there a way to hide the solution? PerlMonks have <readmore> and <spoiler>.

Metaproblem: restate the problem so that it has a determined answer.

An honors pupil Francesco was born in a year where the product of the digits of the year equals the square of some natural number, n. The year is now 2005, and he's waiting for the year when his age will be equal to that natural number, n. In how many years will Francesco celebrate the date?

→ 7

code of conduct - report abuse