# HG changeset patch # User Shlomi Fish # Date 1384015158 -7200 # Node ID c4eb26cb04419f641640b45356d499ebb968dd10 # Parent 61614fe5dedf60ae00c2dd419956ee661931cf0f Solved 137 based on a web solution. See http://www.mathblog.dk/project-euler-137-fibonacci-golden-nuggets/ . diff --git a/project-euler/137/euler-137-2.pl b/project-euler/137/euler-137-2.pl new file mode 100644 --- /dev/null +++ b/project-euler/137/euler-137-2.pl @@ -0,0 +1,24 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Math::GMP qw(:constant); + +my $this_fib = 1; +my$prev_fib = 1; + +my $k = 2; +my$count = 1; +while (1) +{ + ($prev_fib,$this_fib) = ($this_fib,$prev_fib+$this_fib); +$k++; + + if ($k % 2 == 1) + { + print "${count}-th Golden Nugget: ", ($prev_fib*$this_fib), "\n"; + \$count++; + } +} + diff --git a/project-euler/137/html-analysis.html b/project-euler/137/html-analysis.html --- a/project-euler/137/html-analysis.html +++ b/project-euler/137/html-analysis.html @@ -78,6 +78,11 @@ \text{rational iff (N+1)^2+4N^2 is a whole square.} + (N+1)^2+(2N)^2 = T^2 + + T^2-(2N)^2 = (N+1)^2 + (T-2N)(T+2N) = (N+1)^2 + (T-(N+1))(T+(N+1)) = (2N)^2 \]