From f5a0d303bcf96a45ccc8db6bb9a8b3fec4d5add5 Mon Sep 17 00:00:00 2001 From: Adam Russell Date: Mon, 16 May 2022 19:42:36 -0400 Subject: cleaned up code --- challenge-164/adam-russell/perl/ch-2.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/challenge-164/adam-russell/perl/ch-2.pl b/challenge-164/adam-russell/perl/ch-2.pl index 356b738b68..39c323cbab 100644 --- a/challenge-164/adam-russell/perl/ch-2.pl +++ b/challenge-164/adam-russell/perl/ch-2.pl @@ -1,7 +1,7 @@ use strict; use warnings; ## -# W +# Write a script to find the first 8 Happy Numbers in base 10. ## use boolean; use constant N => 8; @@ -10,12 +10,12 @@ sub happy{ my $n = shift; my @seen; my $pdi = sub{ - my $x = shift; + my $n = shift; my $total = 0; { - $total += ($x % 10)**2; - $x = int($x / 10); - redo if $x > 0; + $total += ($n % 10)**2; + $n = int($n / 10); + redo if $n > 0; } return $total; }; @@ -33,7 +33,7 @@ MAIN:{ { $i++; push @happy, $i if happy($i); - redo if @happy < 8; + redo if @happy < N; } print join(", ", @happy) . "\n"; } -- cgit