<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Project Euler in F# - Problem 1</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx</link><description>With the latest news about baking F# into Visual Studio I figured re-solving the problems from Project Euler would be a great way to learn F# and hopefully come up with cleaner solutions. This post will go over my solution for problem 1 in F#.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Project Euler in F# - Problem 1</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx#5655453</link><pubDate>Wed, 24 Oct 2007 21:47:36 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5655453</guid><dc:creator>Bassam Abdul-Baki</dc:creator><description>&lt;p&gt;Good idea. &amp;nbsp;However, it didn't work, using the latest F# compiler, without adding a couple of in's for the two latter let's.&lt;/p&gt;
</description></item><item><title>re: Project Euler in F# - Problem 1</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx#5655989</link><pubDate>Wed, 24 Oct 2007 22:37:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5655989</guid><dc:creator>ChrSmith</dc:creator><description>&lt;p&gt;Thanks for the note! &amp;nbsp;Yes, you can either add the 'in' keyword or declare #light at the top of the file. Don Syme has more information at:&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://blogs.msdn.com/dsyme/archive/2006/08/24/715626.aspx"&gt;http://blogs.msdn.com/dsyme/archive/2006/08/24/715626.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I've updated my post.&lt;/p&gt;
</description></item><item><title>re: Project Euler in F# - Problem 1</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx#5659055</link><pubDate>Thu, 25 Oct 2007 03:36:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5659055</guid><dc:creator>Bassam Abdul-Baki</dc:creator><description>&lt;p&gt;My bad, first time using F# and the Euler relation intrigued me. &amp;nbsp;Although, I could swear the script that F# generated had #light somewhere at the top. &amp;nbsp;However, I'll try &lt;/p&gt;
</description></item><item><title>re: Project Euler in F# - Problem 1</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx#5685616</link><pubDate>Fri, 26 Oct 2007 08:40:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5685616</guid><dc:creator>Robert Pickering</dc:creator><description>&lt;p&gt;Hi Chris,&lt;/p&gt;
&lt;p&gt;Nice effort, here are a couple of alterantive implmentations, which are a little shorter, first you could use a filter instead of adding the Mod35 predicated to your fold function:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;let problem1 = &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[1 .. 999]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;gt; Seq.filter (fun x -&amp;gt; x % 3 = 0 || x % 5 = 0)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;gt; Seq.fold (+) 0 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;printfn &amp;quot;Problem 1 = %d&amp;quot; problem1&lt;/p&gt;
&lt;p&gt;Alternatively you can use step feature list comprehensions to remove any need to for filtering:&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;let problem1 = &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[1 .. 3 .. 999] @ [1 .. 5 .. 999]&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;gt; Seq.fold (+) 0 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;printfn &amp;quot;Problem 1 = %d&amp;quot; problem1&lt;/p&gt;</description></item><item><title>re: Project Euler in F# - Problem 1</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx#6142105</link><pubDate>Mon, 12 Nov 2007 18:30:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6142105</guid><dc:creator>code17</dc:creator><description>&lt;p&gt;try this:&lt;/p&gt;
&lt;p&gt;Seq.fold1 (+) {for i in 1..999 when i%3*i%5=0 -&amp;gt; i}&lt;/p&gt;
</description></item><item><title>Joining the F# team</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx#6438492</link><pubDate>Tue, 20 Nov 2007 20:38:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6438492</guid><dc:creator>Chris Smith's completely unique view</dc:creator><description>&lt;p&gt;I'm please to announce that starting Monday I'll be joining the F# team as (currently) the only full-time tester. I'm super-excited about this for many reasons, but the biggest is knowing what an impact I'll have. Without a doubt F# will change the .Net&lt;/p&gt;
</description></item><item><title>Week 2: My adventures with Euler #2</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx#7483333</link><pubDate>Wed, 06 Feb 2008 08:16:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7483333</guid><dc:creator>Joel Lanciaux</dc:creator><description>&lt;p&gt;Week 2: My adventures with Euler #2&lt;/p&gt;
</description></item><item><title>Robert Pickering is Incorrect</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx#9251765</link><pubDate>Wed, 24 Dec 2008 16:25:21 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9251765</guid><dc:creator>Michael de la Maza</dc:creator><description>&lt;p&gt;Note that the second solution that Robert Pickering gives above is incorrect.&lt;/p&gt;
</description></item><item><title>re: Project Euler in F# - Problem 1</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx#9391225</link><pubDate>Mon, 02 Feb 2009 22:24:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9391225</guid><dc:creator>Daniel Jackson</dc:creator><description>&lt;p&gt;@ Michael de la Maza&lt;/p&gt;
&lt;p&gt;The second solution Pickering has provided should begin the list comprehension from 0 rather than 1.&lt;/p&gt;
</description></item><item><title>re: Project Euler in F# - Problem 1</title><link>http://blogs.msdn.com/chrsmith/archive/2007/10/23/Project-Euler-in-F_2300_-_2D00_-Problem-1.aspx#9391267</link><pubDate>Mon, 02 Feb 2009 22:40:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9391267</guid><dc:creator>Daniel Jackson</dc:creator><description>&lt;p&gt;@ Michael de la Maza&lt;/p&gt;
&lt;p&gt;Starting from 0 rather than 1 is more right, but only half way right. &amp;nbsp; Appending the two lists [1 .. 3 .. 999] @ [1 .. 5 .. 999] also includes duplicate numbers that are divisable by both 3 and 5.&lt;/p&gt;
&lt;p&gt;val it : int list&lt;/p&gt;
&lt;p&gt;= [15; 30; 45; 60; 75; 90; 105; 120; 135; 150; 165; 180; 195; 210; 225; 240;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; 255; 270; 285; 300; 315; 330; 345; 360; 375; 390; 405; 420; 435; 450; 465;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; 480; 495; 510; 525; 540; 555; 570; 585; 600; 615; 630; 645; 660; 675; 690;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; 705; 720; 735; 750; 765; 780; 795; 810; 825; 840; 855; 870; 885; 900; 915;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; 930; 945; 960; 975; 990]&lt;/p&gt;
</description></item></channel></rss>