blob: 12147cea4e550a89f13fd01e4d217273408fd043 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/usr/bin/env perl
#
# Write a script that finds the first square number that has at least 5 distinct
# digits
################################################################################
use strict;
use warnings;
# Compute distinct digits of the given number
sub distinct {
my $n = shift;
my %uniq; # Poor man's set
$uniq{$_} = 1 foreach split(//, $n);
return keys %uniq;
}
my $n = 0;
$n++ while distinct($n**2) != 5;
print "$n ($n**2 = ", $n**2, ")\n";
|