<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Factorial Challenge: Python, Perl, Ruby, and C</title>
	<atom:link href="http://adammonsen.com/post/173/feed" rel="self" type="application/rss+xml" />
	<link>http://adammonsen.com/post/173</link>
	<description>blog and sundries of Adam Monsen</description>
	<pubDate>Tue, 06 Jan 2009 04:22:56 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Help</title>
		<link>http://adammonsen.com/post/173#comment-11868</link>
		<dc:creator>Help</dc:creator>
		<pubDate>Mon, 10 Nov 2008 18:32:12 +0000</pubDate>
		<guid isPermaLink="false">#comment-11868</guid>
		<description>Hi, I've been desperately searching how to (in ruby) use the factorial in ruby, and as my friend only introduced me to ruby yesterday I was hoping you could explain to me, in dumbed down terms, how to use it. If not, could you tell me where to go to ask?
thanks
Andrew</description>
		<content:encoded><![CDATA[<p>Hi, I&#8217;ve been desperately searching how to (in ruby) use the factorial in ruby, and as my friend only introduced me to ruby yesterday I was hoping you could explain to me, in dumbed down terms, how to use it. If not, could you tell me where to go to ask?<br />
thanks<br />
Andrew</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: acc</title>
		<link>http://adammonsen.com/post/173#comment-3801</link>
		<dc:creator>acc</dc:creator>
		<pubDate>Tue, 23 Jan 2007 17:33:48 +0000</pubDate>
		<guid isPermaLink="false">#comment-3801</guid>
		<description>Recursive version, equivalent to Ruby, is also fast, once you install the already mentioned package.

&lt;blockquote&gt;&lt;pre&gt;
#!/usr/bin/perl -w
use strict;

use Math::BigInt lib =&#62; 'GMP';

use bignum;

sub fact
{
    my $n = $_[0];
    ( $n == 0 ) 
    ? 1
    : $n * fact( $n - 1 );
}

print fact( $ARGV[0] ), "\n"
&lt;/pre&gt;&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>Recursive version, equivalent to Ruby, is also fast, once you install the already mentioned package.</p>
<blockquote><pre>
#!/usr/bin/perl -w
use strict;

use Math::BigInt lib =&gt; 'GMP';

use bignum;

sub fact
{
    my $n = $_[0];
    ( $n == 0 )
    ? 1
    : $n * fact( $n - 1 );
}

print fact( $ARGV[0] ), "\n"
</pre>
</blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: acc</title>
		<link>http://adammonsen.com/post/173#comment-3800</link>
		<dc:creator>acc</dc:creator>
		<pubDate>Tue, 23 Jan 2007 17:24:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-3800</guid>
		<description>Your Perl run was slow only because you didn't actually use GMP library there: Perl "gracefully" fails to Perl-written implementation, when GMP is not installed. You should start your PPM (Perl Package Manager) and install Math::BigInt::GMP package. Then, Perl would be just as fast as C, for your starting example.</description>
		<content:encoded><![CDATA[<p>Your Perl run was slow only because you didn&#8217;t actually use GMP library there: Perl &#8220;gracefully&#8221; fails to Perl-written implementation, when GMP is not installed. You should start your PPM (Perl Package Manager) and install Math::BigInt::GMP package. Then, Perl would be just as fast as C, for your starting example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://adammonsen.com/post/173#comment-2395</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Sun, 17 Dec 2006 02:18:03 +0000</pubDate>
		<guid isPermaLink="false">#comment-2395</guid>
		<description>Here's a version that's a bit simpler and isn't recursive:
&lt;blockquote&gt;&lt;pre&gt;class Fixnum
    def factorial
        (2..self).inject(1) { &#124;product, i&#124; product*i }
    end
end&lt;/pre&gt;&lt;/blockquote&gt;

It's a bit easier to use to because you can just call it this way:
p 6.factorial</description>
		<content:encoded><![CDATA[<p>Here&#8217;s a version that&#8217;s a bit simpler and isn&#8217;t recursive:</p>
<blockquote><pre>class Fixnum
    def factorial
        (2..self).inject(1) { |product, i| product*i }
    end
end</pre>
</blockquote>
<p>It&#8217;s a bit easier to use to because you can just call it this way:<br />
p 6.factorial</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: muyufan</title>
		<link>http://adammonsen.com/post/173#comment-987</link>
		<dc:creator>muyufan</dc:creator>
		<pubDate>Sun, 01 Oct 2006 09:20:43 +0000</pubDate>
		<guid isPermaLink="false">#comment-987</guid>
		<description>I just exec the factorial.py file

&lt;blockquote&gt;&lt;pre&gt;import time
start=time.clock()
def f(n):return reduce(lambda x,y:x*y,range(1,n+1))
f(n) 
print "the time is :",time.clock()-start&lt;/pre&gt;&lt;/blockquote&gt;

in my 1.6G AMD(Duron) the result is:
40!: 0.0004 (s)
10000!: 0.22 (s)
100000!: 202 (s)</description>
		<content:encoded><![CDATA[<p>I just exec the factorial.py file</p>
<blockquote><pre>import time
start=time.clock()
def f(n):return reduce(lambda x,y:x*y,range(1,n+1))
f(n)
print "the time is :",time.clock()-start</pre>
</blockquote>
<p>in my 1.6G AMD(Duron) the result is:<br />
40!: 0.0004 (s)<br />
10000!: 0.22 (s)<br />
100000!: 202 (s)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pjh</title>
		<link>http://adammonsen.com/post/173#comment-170</link>
		<dc:creator>pjh</dc:creator>
		<pubDate>Tue, 27 Sep 2005 00:01:38 +0000</pubDate>
		<guid isPermaLink="false">#comment-170</guid>
		<description>&lt;p&gt;just for fun, the original ruby function can be replaced with:&lt;/p&gt;

&lt;blockquote&gt;&lt;pre&gt;
def fact(n)
  n == 0 ? 1 : n * fact(n-1)
end
&lt;/pre&gt;&lt;/blockquote&gt;</description>
		<content:encoded><![CDATA[<p>just for fun, the original ruby function can be replaced with:</p>
<blockquote><pre>
def fact(n)
  n == 0 ? 1 : n * fact(n-1)
end
</pre>
</blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patrick</title>
		<link>http://adammonsen.com/post/173#comment-169</link>
		<dc:creator>Patrick</dc:creator>
		<pubDate>Mon, 22 Aug 2005 00:49:00 +0000</pubDate>
		<guid isPermaLink="false">#comment-169</guid>
		<description>Adam (whose weblog requires I log in to leave comments directly) notices that python and ruby's performance seem great while C is (naturally) very fast. Perl is in the mix, too, and he kindly doesn't tear it apart though based on the numbers he would seem justified in doing so. I wondered if perl was realy that slow so I decided to take a look...</description>
		<content:encoded><![CDATA[<p>Adam (whose weblog requires I log in to leave comments directly) notices that python and ruby&#8217;s performance seem great while C is (naturally) very fast. Perl is in the mix, too, and he kindly doesn&#8217;t tear it apart though based on the numbers he would seem justified in doing so. I wondered if perl was realy that slow so I decided to take a look&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
