<?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>A Tempest of Thoughts &#187; Euler</title>
	<atom:link href="http://tempe.st/category/euler/feed/" rel="self" type="application/rss+xml" />
	<link>http://tempe.st</link>
	<description>aka blog.to_int(:inig)</description>
	<lastBuildDate>Thu, 13 May 2010 09:54:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How I beat Project Euler using Erlang: Christmas Edition, problem one</title>
		<link>http://tempe.st/2007/12/how-i-beat-project-euler-using-erlang-christmas-edition-problem-one/</link>
		<comments>http://tempe.st/2007/12/how-i-beat-project-euler-using-erlang-christmas-edition-problem-one/#comments</comments>
		<pubDate>Wed, 26 Dec 2007 11:52:56 +0000</pubDate>
		<dc:creator>Giovanni Intini</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Euler]]></category>

		<guid isPermaLink="false">http://tempe.st/2007/12/how-i-beat-project-euler-using-erlang-christmas-edition-problem-one/</guid>
		<description><![CDATA[Merry Christmas everyone! It&#8217;s been a long time since I wrote a post, but I&#8217;ve been very busy coding, and I could only muster some posts for Stacktrace, so express all your Christmas-y goodness and pardon me On Stacktrace we just started posting in depth analysis of the Project Euler problems, and I decided to [...]]]></description>
			<content:encoded><![CDATA[	<p>Merry Christmas everyone!</p>
	<p>It&#8217;s been a long time since I wrote a post, but I&#8217;ve been very busy coding, and I could only muster some posts for <a href="http://stacktrace.it">Stacktrace</a>, so express all your Christmas-y goodness and pardon me <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
	<p>On Stacktrace <a href="http://stacktrace.it/articoli/2007/12/progetto-eulero-problema-1">we just started posting</a> in depth analysis of the <a href="http://projecteuler.net">Project Euler</a> problems, and I decided to try and solve them using Erlang, since I already did using Ruby a couple of years ago.</p>
	<p>The first problem is quite simple: </p>
	<blockquote>
		<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. Find the sum of all the multiples of 3 or 5 below 1000. </p>
	</blockquote>
	<p>I will not try to give you the clever solution since this problem is quite simple, and the brute force solutions works fine <img src='http://tempe.st/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="erlang" style="font-family:monospace;"><span style="color: #014ea4;">-</span><span style="color: #5400b3;">module</span><span style="color: #109ab8;">&#40;</span>p1<span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span> 
<span style="color: #014ea4;">-</span><span style="color: #5400b3;">export</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span>sum_mul<span style="color: #014ea4;">/</span><span style="color: #ff9600;">1</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">.</span> 
&nbsp;
<span style="color: #ff3c00;">sum_mul</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #45b3e6;">H</span>|T<span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff3c00;">valid</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">H</span><span style="color: #109ab8;">&#41;</span> <span style="color: #014ea4;">+</span> <span style="color: #ff3c00;">sum_mul</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">T</span><span style="color: #109ab8;">&#41;</span><span style="color: #6bb810;">;</span>
<span style="color: #ff3c00;">sum_mul</span><span style="color: #109ab8;">&#40;</span><span style="color: #109ab8;">&#91;</span><span style="color: #109ab8;">&#93;</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff9600;">0.</span>
<span style="color: #ff3c00;">valid</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">H</span><span style="color: #109ab8;">&#41;</span> <span style="color: #186895;">when</span> <span style="color: #45b3e6;">H</span> <span style="color: #014ea4;">rem</span> <span style="color: #ff9600;">3</span> <span style="color: #014ea4;">=:=</span> <span style="color: #ff9600;">0</span><span style="color: #6bb810;">;</span> <span style="color: #45b3e6;">H</span> <span style="color: #014ea4;">rem</span> <span style="color: #ff9600;">5</span> <span style="color: #014ea4;">=:=</span> <span style="color: #ff9600;">0</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #45b3e6;">H</span><span style="color: #6bb810;">;</span>
<span style="color: #ff3c00;">valid</span><span style="color: #109ab8;">&#40;</span><span style="color: #45b3e6;">H</span><span style="color: #109ab8;">&#41;</span> <span style="color: #6bb810;">-&gt;</span> <span style="color: #ff9600;">0.</span></pre></div></div>

	<p>To get the solution just call _sum_mul(lists:seq(1,999))_.</p>
	<p>Have a Merry Erlang Christmas!</p>

 ]]></content:encoded>
			<wfw:commentRss>http://tempe.st/2007/12/how-i-beat-project-euler-using-erlang-christmas-edition-problem-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
