Skip to content

Instantly share code, notes, and snippets.

@tmn
Created December 23, 2014 01:07
Show Gist options
  • Save tmn/4d664a90d3c5f3bf0b87 to your computer and use it in GitHub Desktop.
Save tmn/4d664a90d3c5f3bf0b87 to your computer and use it in GitHub Desktop.
#!/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