summaryrefslogtreecommitdiffstats
path: root/055.pl
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2016-09-29 04:01:09 -0400
committerJesse Luehrs <doy@tozt.net>2016-09-29 04:01:09 -0400
commit2789f9ea1968e6eb0defe06c92cb7a7f544191b3 (patch)
treeb2f75da2d6920d2fc36e97b4cd9bf5ae9fda0f04 /055.pl
parent65f117a3696ccaf5c0770968b8a5d3384b2a20c7 (diff)
downloadprojecteuler-2789f9ea1968e6eb0defe06c92cb7a7f544191b3.tar.gz
projecteuler-2789f9ea1968e6eb0defe06c92cb7a7f544191b3.zip
problem 55
Diffstat (limited to '055.pl')
-rw-r--r--055.pl23
1 files changed, 23 insertions, 0 deletions
diff --git a/055.pl b/055.pl
new file mode 100644
index 0000000..e695605
--- /dev/null
+++ b/055.pl
@@ -0,0 +1,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;
+}