summaryrefslogtreecommitdiffstats
path: root/055.pl
blob: e695605c75cf73e6fec01a8101ad37bd377b2bc6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env perl
use strict;
use warnings;
use 5.014;

use bigint;

my $count = 0;
for my $i (1..9999) {
    $count++ if lychrel(Math::BigInt->new($i));
}

say $count;

sub lychrel {
    my ($i) = @_;

    for my $iter (1..50) {
        $i += reverse($i);
        return if $i == reverse($i);
    }
    return 1;
}