summaryrefslogtreecommitdiffstats
path: root/045.pl
diff options
context:
space:
mode:
Diffstat (limited to '045.pl')
-rwxr-xr-x045.pl13
1 files changed, 13 insertions, 0 deletions
diff --git a/045.pl b/045.pl
new file mode 100755
index 0000000..a47399d
--- /dev/null
+++ b/045.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+for my $h_idx (144..100000) {
+ my $hex = $h_idx * (2 * $h_idx - 1);
+ my $tri_test = -1/2 + sqrt(1 + 8 * $hex) / 2;
+ next unless $tri_test == int($tri_test);
+ my $pent_test = 1/6 + sqrt(1 + 24 * $hex) / 6;
+ next unless $pent_test == int($pent_test);
+ print "$tri_test $pent_test $h_idx $hex\n";
+ last;
+}