diff options
Diffstat (limited to '009/ch1.pl')
-rwxr-xr-x | 009/ch1.pl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/009/ch1.pl b/009/ch1.pl new file mode 100755 index 0000000..e98223d --- /dev/null +++ b/009/ch1.pl @@ -0,0 +1,17 @@ +#!/usr/bin/env perl + +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"; |