View Single Post
Old 08-8-2014, 06:42 AM   #425
stargroup100
behanjc & me are <3'ers
FFR Simfile AuthorFFR Music Producer
 
Join Date: Jul 2006
Posts: 2,051
Default Re: The Project Euler thread

So recently I've gotten more motivation to do smartsy stuff so I picked this up again. (unfortunately we can't have our accounts back yet, if ever)

In any case, I'm currently working on 65. What I don't understand is how someone would go about finding a solution more rigorously.


I tried to find a recursive method to quickly find the fraction I needed, and used a large integer "class"/object to hold the numerator and denominator.

In (x+k+1)/(2x+2k+1), we start with k = 66, x = 1/2.
(2*(1/2)+2*66+1)/(1/2+66+1) = x_1
(2*(x_1)+2*64+1)/(x_1+64+1) = x_2
(2*(x_2)+2*62+1)/(x_2+62+1) = x_3
(2*(x_3)+2*60+1)/(x_3+60+1) = x_4
...
(2*(x_32)+2*4+1)/(x_32+4+1) = x_33
(8+3x_33)/(3+x_33) will give us our final fraction.

Code:
	var num = 1;
	var denom = 1;
	var tempnum;
	
	for (var k = 6; k >= 4; k=k-2) {
		tempnum = num + (k*denom) + denom;
		denom = (2*num) + (2*k*denom) + denom;
		num = tempnum;
	}
	console.log('The fraction is ' + num + '/' + denom);

	tempnum = (8*denom) + (3*num);
	denom = (3*denom) + num;
	num = tempnum;
	
	console.log('The fraction is ' + num + '/' + denom);
I'm pretty sure this gives me the final fraction, but I can't tell whether or not this needs to be simplified, and if so, I still won't get the right answer.


On the other hand, there's an easily recognizable pattern in the numerator: n_k = a_k * n_[k-1] + n_[k-2]

This easily gives me the correct answer, but I can't show why this pattern holds true.

What do?
__________________
Rhythm Simulation Guide
Comments, criticism, suggestions, contributions, etc. are all welcome.

Piano Etude Demon Fire sheet music
stargroup100 is offline   Reply With Quote