re: Compute Smart, Not Hard VIEW POST

re: Although I am absolutely agree on a preface, all the “Francesco was born” riddles are best solved with a brute force :)

Is Francesco a very smart 3yo? Or 0 is involved in the multiplication?


1999 is 93 or 36 or 272.

Literally the first brute force hit after zeroes :)

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 bruteforce for this task is fine since I do not even need a paper to give the answer(s).

(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