From b0609bd3cfd84c803596de9ea615829c712492b8 Mon Sep 17 00:00:00 2001 From: Guillermo Ramos Date: Thu, 23 May 2019 10:55:17 +0200 Subject: [009#1] --- 009/ch1.pl | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 009/ch1.pl (limited to '009') 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"; -- cgit v1.2.3