Created
December 23, 2014 01:07
-
-
Save tmn/4d664a90d3c5f3bf0b87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
my @res; | |
sub calc { | |
eval join '+', map {$_**2} split //, shift; | |
} | |
for my $i (1..50) { | |
my %hash, $num = calc $i; | |
while ($num != 1 && !exists $hash{$num}) { | |
$hash{$num} = 1; | |
$num = calc $num; | |
} | |
push @res, $i if $num == 1; | |
} | |
print join ',', @res; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment