DEV Community

Discussion on: Compute Smart, Not Hard

 
awwsmm profile image
Andrew (he/him)

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

Thread Thread
 
choroba profile image
E. Choroba • Edited

1988 is 3^2 * 8^2, and that's it.

#!/usr/bin/perl
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
}
Enter fullscreen mode Exit fullscreen mode

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