<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kenneth &#187; Project Euler</title>
	<atom:link href="http://kennethlynne.net/category/project-euler/feed/" rel="self" type="application/rss+xml" />
	<link>http://kennethlynne.net</link>
	<description></description>
	<lastBuildDate>Sat, 01 May 2010 23:25:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Project Euler &#8211; Problem 8</title>
		<link>http://kennethlynne.net/project-euler/project-euler-problem-8/</link>
		<comments>http://kennethlynne.net/project-euler/project-euler-problem-8/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 17:30:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Project Euler]]></category>

		<guid isPermaLink="false">http://kennethlynne.net/?p=267</guid>
		<description><![CDATA[Problem description: http://projecteuler.net/index.php?section=problems&#38;id=8 Find the greatest product of five consecutive digits in the 1000-digit number. 731671765313&#8230;0752963450 (Check problem page for full length number) My solution: The logic behind: Simply put: .. Solution (PHP): &#60;?php $string = '7316717...2963450'; for ($i = 0; $i &#60; 1000; $i++) { $nyverdi = $string[$i]*$string[$i+1]*$string[$i+2]*$string[$i+3]*$string[$i+4]; if ($nyverdi &#62; $verdi) {$verdi = [...]]]></description>
			<content:encoded><![CDATA[<h4><strong><strong><strong><strong>Problem description:</strong></strong></strong></strong></h4>
<p><a href="http://projecteuler.net/index.php?section=problems&amp;id=1">http://projecteuler.net/index.php?section=problems&amp;id=8</a></p>
<div>
<p>Find the greatest product of five consecutive digits in the 1000-digit number.</p>
<p>731671765313&#8230;0752963450 (Check problem page for full length number)</p>
</div>
<hr />
<h4><strong><strong>My solution:</strong></strong></h4>
<h4><strong><br />
</strong></h4>
<h5>The logic behind:</h5>
<p>Simply put: ..</p>
<h5>Solution (PHP):</h5>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
$string <span class="phpOperator">=</span> <span class="phpString">'7316717<span class="phpOperator">.</span>.<span class="phpOperator">.</span>2963450'</span><span class="phpText">;</span>
<span class="phpKeyword">
for </span><span class="phpOperator">(</span>$i <span class="phpOperator">=</span> 0; $i <span class="phpOperator">&lt;</span> 1000; $i<span class="phpOperator"><span class="phpOperator">+</span><span class="phpOperator">+</span></span><span class="phpOperator">)</span>
<span class="phpOperator">{</span>
$nyverdi <span class="phpOperator">=</span> $string<span class="phpOperator">[</span>$i<span class="phpOperator">]</span>*$string<span class="phpOperator">[</span>$i<span class="phpOperator">+</span><span class="phpNumber">1</span><span class="phpOperator">]</span>*$string<span class="phpOperator">[</span>$i<span class="phpOperator">+</span><span class="phpNumber">2</span><span class="phpOperator">]</span>*$string<span class="phpOperator">[</span>$i<span class="phpOperator">+</span><span class="phpNumber">3</span><span class="phpOperator">]</span>*$string<span class="phpOperator">[</span>$i<span class="phpOperator">+</span><span class="phpNumber">4</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span>$nyverdi <span class="phpOperator">&gt;</span> $verdi<span class="phpOperator">)</span> <span class="phpOperator">{</span>$verdi <span class="phpOperator">=</span> $nyverdi<span class="phpText">;</span><span class="phpOperator">}</span>
<span class="phpOperator">}</span>
<span class="phpFunction">echo</span> $verdi<span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<div style="text-align: center; width: 90px;"><fieldset class="spoiler">
			<legend>
				<input type="button" onclick="tiny_spoiler('Answerzsuaajwzra')" id="Answerzsuaajwzra_button" value="+" />
				Answer
			</legend>
			<div id="Answerzsuaajwzra"><strong>40824</strong>
			</div>
		</fieldset></div>
<div id="_mcePaste" style="position: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;">
<p>An irrational decimal fraction is created by concatenating the positive integers:</p>
<p style="text-align: center;">0.12345678910<span style="color: #dd0000; font-size: 14pt;">1</span>112131415161718192021&#8230;</p>
<p>It can be seen that the 12<img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="^(" /><sup>th</sup><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> digit of the fractional part is 1.</p>
<p>If <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub><em>n</em></sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> represents the <em>n</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="^(" /><sup>th</sup><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> digit of the fractional part, find the value of the following expression.</p>
<p><em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>1</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>10</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>100</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>1000</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>10000</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>100000</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>1000000</sub></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://kennethlynne.net/project-euler/project-euler-problem-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler &#8211; Problem 9</title>
		<link>http://kennethlynne.net/project-euler/project-euler-problem-9/</link>
		<comments>http://kennethlynne.net/project-euler/project-euler-problem-9/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 13:17:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Project Euler]]></category>

		<guid isPermaLink="false">http://kennethlynne.net/?p=247</guid>
		<description><![CDATA[Problem description: http://projecteuler.net/index.php?section=problems&#38;id=9 A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. [...]]]></description>
			<content:encoded><![CDATA[<h4><strong><strong><strong><strong>Problem description:</strong></strong></strong></strong></h4>
<p><a href="http://projecteuler.net/index.php?section=problems&amp;id=1">http://projecteuler.net/index.php?section=problems&amp;id=9</a></p>
<div>
<div class="problem_content">
<p>A Pythagorean triplet is a set of three natural numbers, <var>a</var> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_lt.gif" border="0" alt="&lt;" width="10" height="10" /> <var>b</var> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_lt.gif" border="0" alt="&lt;" width="10" height="10" /> <var>c</var>, for which,</p>
<div style="text-align: left;"><var>a</var><sup>2</sup> + <var>b</var><sup>2</sup> = <var>c</var><sup>2</sup></div>
<p>For example, 3<sup>2</sup> + 4<sup>2</sup> = 9 + 16 = 25 = 5<sup>2</sup>.</p>
<p>There exists exactly one Pythagorean triplet for which <var>a</var> + <var>b</var> + <var>c</var> = 1000.<br />
Find the product <var>abc</var>.</p>
</div>
</div>
<hr />
<h4><strong><strong>My solution:</strong></strong></h4>
<h4><strong><br />
</strong></h4>
<h5>The logic behind:</h5>
<p>My initial approach was to simplify the equation by using the given information and some algebra, resulting in the following equation:</p>
<p>b^2 = c<sup>2</sup> &#8211; a<sup>2</sup><br />
b = 1000 &#8211; a &#8211; c</p>
<p>(1000 &#8211; a &#8211; c)<sup>2</sup> = c<sup>2</sup> &#8211; a<sup>2</sup><br />
1000<sup>2</sup> &#8211; 1000a &#8211; 1000c &#8211; 1000a &#8211; a<sup>2</sup> &#8211; ac &#8211; 1000c &#8211; ac &#8211; c<sup>2</sup> = c<sup>2</sup> &#8211; a<sup>2</sup><br />
2000a + 2000c + 2ac = 1000<sup>2</sup><br />
1000a + 1000c + ac = 500000</p>
<p>Eventually i reconsidered my approach.<br />
As i later was to discover, this pitch wasn&#8217;t a bad idea after all, but i eventually went for a good ol&#8217; brute force.<br />
The equation could have been used to shorten the time required to solve the problem by brute force a lot, but my solution spits out the correct answer within 5 secs so what the heck.</p>
<h5>Solution (PHP):</h5>
<pre class="php"> <span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpKeyword">
for </span><span class="phpOperator">(</span>$a <span class="phpOperator">=</span> <span class="phpNumber">1</span><span class="phpText">;</span> $a <span class="phpOperator">&lt;</span> 800; $a<span class="phpOperator"><span class="phpOperator">+</span><span class="phpOperator">+</span></span><span class="phpOperator">)</span>
<span class="phpOperator">{</span>
<span class="phpKeyword">
for </span><span class="phpOperator">(</span>$b <span class="phpOperator">=</span> $a<span class="phpText">;</span> $b <span class="phpOperator">&lt;</span> 1000; $b<span class="phpOperator"><span class="phpOperator">+</span><span class="phpOperator">+</span></span><span class="phpOperator">)</span>
<span class="phpOperator">{</span>
$c <span class="phpOperator">=</span> 1000-$a-$b<span class="phpText">;</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span><span class="phpFunction">bcpow</span><span class="phpOperator">(</span>$a,<span class="phpNumber">2</span><span class="phpOperator">)</span><span class="phpOperator">+</span><span class="phpFunction">bcpow</span><span class="phpOperator">(</span>$b,<span class="phpNumber">2</span><span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpOperator"><span class="phpOperator">=</span>=</span><span class="phpFunction">bcpow</span><span class="phpOperator">(</span>$c,<span class="phpNumber">2</span><span class="phpOperator">)</span> <span class="phpComment">//GREAT SUCCESS<span class="phpOperator">!</span>
</span><span class="phpOperator">{</span>
<span class="phpFunction">echo</span> $a*$b*$c<span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpOperator">}</span>
<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<div style="text-align: center; width: 90px;"><fieldset class="spoiler">
			<legend>
				<input type="button" onclick="tiny_spoiler('Answeriyikmzyfit')" id="Answeriyikmzyfit_button" value="+" />
				Answer
			</legend>
			<div id="Answeriyikmzyfit"><strong>31875000</strong>
			</div>
		</fieldset></div>
]]></content:encoded>
			<wfw:commentRss>http://kennethlynne.net/project-euler/project-euler-problem-9/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler &#8211; Problem 40</title>
		<link>http://kennethlynne.net/project-euler/project-euler-problem-40/</link>
		<comments>http://kennethlynne.net/project-euler/project-euler-problem-40/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 20:37:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Project Euler]]></category>

		<guid isPermaLink="false">http://kennethlynne.net/?p=243</guid>
		<description><![CDATA[Problem description: http://projecteuler.net/index.php?section=problems&#38;id=40 An irrational decimal fraction is created by concatenating the positive integers: 0.123456789101112131415161718192021&#8230; It can be seen that the 12th digit of the fractional part is 1. If dn represents the nth digit of the fractional part, find the value of the following expression. d1 d10 d100 d1000 d10000 d100000 d1000000 My solution: [...]]]></description>
			<content:encoded><![CDATA[<h4><strong><strong><strong><strong>Problem description:</strong></strong></strong></strong></h4>
<p><a href="http://projecteuler.net/index.php?section=problems&amp;id=1">http://projecteuler.net/index.php?section=problems&amp;id=40</a></p>
<div>
<p>An irrational decimal fraction is created by concatenating the  positive integers:</p>
<p style="text-align: left;">0.12345678910<span style="color: #dd0000; font-size: 14pt;">1</span>112131415161718192021&#8230;</p>
<p>It can be seen that the 12<img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="^(" /><sup>th</sup><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> digit of the fractional part is 1.</p>
<p>If <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub><em>n</em></sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> represents the <em>n</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="^(" /><sup>th</sup><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> digit of the fractional part, find the  value of the following expression.</p>
<p><em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>1</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>10</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>100</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>1000</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>10000</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>100000</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>1000000</sub></p>
</div>
<hr />
<h4><strong><strong>My solution:</strong></strong></h4>
<h4><strong><br />
</strong></h4>
<h5>The logic behind:</h5>
<p>Simply put: Keep increasing n, and add n to the result until the length of the result string reaches a given number.</p>
<h5>Solution (PHP):</h5>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpFunctionKeyword">function</span><span class="htmlText"> d</span><span class="phpOperator">(</span>$ønsketplass<span class="phpOperator">)</span>
<span class="phpOperator">{</span>
<span class="phpKeyword">
while </span><span class="phpOperator">(</span>$loop <span class="phpOperator">&lt;</span> $ønsketplass<span class="phpOperator">)</span>
<span class="phpOperator">{</span>
$loop <span class="phpOperator">=</span> $loop<span class="phpOperator">+</span><span class="phpFunction">strlen</span><span class="phpOperator">(</span>$i<span class="phpOperator">)</span><span class="phpText">;</span>
$streng <span class="phpOperator">.=</span> $i<span class="phpText">;</span>
$i<span class="phpOperator"><span class="phpOperator">+</span><span class="phpOperator">+</span></span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpKeyword">
return </span><span class="phpOperator">(</span><span class="phpFunction">substr</span><span class="phpOperator">(</span>$streng,<span class="phpOperator">(</span>$ønsketplass-<span class="phpNumber">1</span><span class="phpOperator">)</span>,<span class="phpNumber">1</span><span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpFunction">echo</span><span class="htmlText"> d</span><span class="phpOperator">(</span><span class="phpNumber">1</span><span class="phpOperator">)</span>*d<span class="phpOperator">(</span><span class="htmlText">10</span><span class="phpOperator">)</span>*d<span class="phpOperator">(</span><span class="htmlText">100</span><span class="phpOperator">)</span>*d<span class="phpOperator">(</span><span class="htmlText">1000</span><span class="phpOperator">)</span>*d<span class="phpOperator">(</span><span class="htmlText">10000</span><span class="phpOperator">)</span>*d<span class="phpOperator">(</span><span class="htmlText">100000</span><span class="phpOperator">)</span>*d<span class="phpOperator">(</span><span class="htmlText">1000000</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<div style="width: 90px; text-align: center;"><fieldset class="spoiler">
			<legend>
				<input type="button" onclick="tiny_spoiler('Answeraqqtudpeot')" id="Answeraqqtudpeot_button" value="+" />
				Answer
			</legend>
			<div id="Answeraqqtudpeot"><strong>210</strong>
			</div>
		</fieldset></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">
<p>An irrational decimal fraction is created by concatenating the  positive integers:</p>
<p style="text-align: center;">0.12345678910<span style="color: #dd0000; font-size: 14pt;">1</span>112131415161718192021&#8230;</p>
<p>It can be seen that the 12<img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="^(" /><sup>th</sup><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> digit of the fractional part is 1.</p>
<p>If <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub><em>n</em></sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> represents the <em>n</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="^(" /><sup>th</sup><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> digit of the fractional part, find the  value of the following expression.</p>
<p><em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>1</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>10</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>100</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>1000</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>10000</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>100000</sub><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt=")" /> <img style="vertical-align: middle;" src="http://projecteuler.net/images/symbol_times.gif" border="0" alt="×" width="9" height="9" /> <em>d</em><img style="display: none;" src="http://projecteuler.net/index.php?section=problems&amp;id=40" alt="_(" /><sub>1000000</sub></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://kennethlynne.net/project-euler/project-euler-problem-40/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler &#8211; Problem 48</title>
		<link>http://kennethlynne.net/project-euler/project-euler-problem-48/</link>
		<comments>http://kennethlynne.net/project-euler/project-euler-problem-48/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 04:49:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Project Euler]]></category>

		<guid isPermaLink="false">http://kennethlynne.net/?p=241</guid>
		<description><![CDATA[Problem description: http://projecteuler.net/index.php?section=problems&#38;id=48 The series, 11 + 22 + 33 + &#8230; + 1010 = 10405071317. Find the last ten digits of the series, 11 + 22 + 33 + &#8230; + 10001000. My solution: The logic behind: Simply put: Iterate over all numbers between 1 and 1000. For each iteration n, add nn. Code [...]]]></description>
			<content:encoded><![CDATA[<h4><strong><strong><strong><strong>Problem description:</strong></strong></strong></strong></h4>
<p><a href="http://projecteuler.net/index.php?section=problems&amp;id=1">http://projecteuler.net/index.php?section=problems&amp;id=48</a></p>
<div>
<p>The series, 1<sup>1</sup> + 2<sup>2</sup> + 3<sup>3</sup> + &#8230; + 10<sup>10</sup> = 10405071317.</p>
<p>Find the last ten digits of the series, 1<sup>1</sup> + 2<sup>2</sup> + 3<sup>3</sup> + &#8230; + 1000<sup>1000</sup>.</p>
</div>
<hr />
<h4><strong><strong>My solution:</strong></strong></h4>
<h4><strong><br />
</strong></h4>
<h5>The logic behind:</h5>
<p>Simply put: Iterate over all numbers between 1 and 1000. For each iteration <em>n</em>, add n<sup><em>n</em></sup>.<br />
Code uses bcmath functions, as the PHP pow function can&#8217;t handle numbers of this scale.</p>
<h5>Solution (PHP):</h5>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpKeyword">
for </span><span class="phpOperator">(</span>$x <span class="phpOperator">=</span> <span class="phpNumber">1</span><span class="phpText">;</span> $x <span class="phpOperator">&lt;</span> 1000; $x<span class="phpOperator"><span class="phpOperator">+</span><span class="phpOperator">+</span></span><span class="phpOperator">)</span>
<span class="phpOperator">{</span>$sum <span class="phpOperator">=</span> <span class="phpFunction">bcadd</span><span class="phpOperator">(</span>$sum, <span class="phpFunction">bcpow</span><span class="phpOperator">(</span>$x,$x<span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpText">;</span><span class="phpOperator">}</span>
<span class="phpFunction">echo</span> <span class="phpFunction">substr</span><span class="phpOperator">(</span>$sum,<span class="phpFunction">strlen</span><span class="phpOperator">(</span>$sum<span class="phpOperator">)</span>-10,10<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<div style="text-align: center; width: 90px;"><fieldset class="spoiler">
			<legend>
				<input type="button" onclick="tiny_spoiler('Answerqodaxddfoy')" id="Answerqodaxddfoy_button" value="+" />
				Answer
			</legend>
			<div id="Answerqodaxddfoy"><strong>9110846700</strong>
			</div>
		</fieldset></div>
]]></content:encoded>
			<wfw:commentRss>http://kennethlynne.net/project-euler/project-euler-problem-48/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Project Euler &#8211; Problem 1</title>
		<link>http://kennethlynne.net/project-euler/project-euler-problem-1/</link>
		<comments>http://kennethlynne.net/project-euler/project-euler-problem-1/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 17:05:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Project Euler]]></category>

		<guid isPermaLink="false">http://kennethlynne.net/?p=214</guid>
		<description><![CDATA[Problem description: http://projecteuler.net/index.php?section=problems&#38;id=1 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. My solution: The logic behind: Simply put: Iterate over [...]]]></description>
			<content:encoded><![CDATA[<h4><strong><strong><strong><strong>Problem description:</strong></strong></strong></strong></h4>
<p><a href="http://projecteuler.net/index.php?section=problems&amp;id=1">http://projecteuler.net/index.php?section=problems&amp;id=1</a></p>
<p>If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.<br />
Find the sum of all the multiples of 3 or 5 below 1000.</p>
<hr />
<br/></p>
<h4><strong><strong>My solution:</strong></strong></h4>
<h4><strong><br />
</strong></h4>
<h5>The logic behind:</h5>
<p>Simply put: Iterate over all numbers between 0 and 1000, and check if the given number is a multiple of  3 or 5. If the number does satisfy this requirement, add it to the stack.<br />
<br/></p>
<h5>Solution (PHP):</h5>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="htmlText">
Echo </span><span class="phpString">"To be continued<span class="phpOperator">:</span><span class="phpOperator">)</span>"</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<div style="width: 90px; text-align: center;"><fieldset class="spoiler">
			<legend>
				<input type="button" onclick="tiny_spoiler('Answerxxyotptqev')" id="Answerxxyotptqev_button" value="+" />
				Answer
			</legend>
			<div id="Answerxxyotptqev"><strong>233168</strong>
			</div>
		</fieldset></div>
]]></content:encoded>
			<wfw:commentRss>http://kennethlynne.net/project-euler/project-euler-problem-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

