From 67cb894a9ed7a752e21154282858f16f9567124d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 16 May 2009 01:44:16 -0500 Subject: solution for 45 --- 045.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 045.pl (limited to '045.pl') 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; +} -- cgit v1.2.3-54-g00ecf