<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Python: Highest common factor of two numbers</title>
	<atom:link href="http://www.stealthcopter.com/blog/2009/12/python-highest-common-factor/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stealthcopter.com/blog/2009/12/python-highest-common-factor/</link>
	<description>Android, Linux, Python and stealthcopters</description>
	<lastBuildDate>Thu, 09 Sep 2010 13:38:47 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: st0le</title>
		<link>http://www.stealthcopter.com/blog/2009/12/python-highest-common-factor/comment-page-1/#comment-2131</link>
		<dc:creator>st0le</dc:creator>
		<pubDate>Wed, 26 May 2010 10:36:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=228#comment-2131</guid>
		<description>The Binary GCD Algorithm is faster on a Computer...because a lot of its instructions are bit-shifts. So it is faster than Euclid&#039;s on a Computer.

However, i&#039;m not sure how python does it bit shift (maybe it uses multiply/divide by 2)</description>
		<content:encoded><![CDATA[<p>The Binary GCD Algorithm is faster on a Computer&#8230;because a lot of its instructions are bit-shifts. So it is faster than Euclid&#8217;s on a Computer.</p>
<p>However, i&#8217;m not sure how python does it bit shift (maybe it uses multiply/divide by 2)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: morlockhq</title>
		<link>http://www.stealthcopter.com/blog/2009/12/python-highest-common-factor/comment-page-1/#comment-50</link>
		<dc:creator>morlockhq</dc:creator>
		<pubDate>Tue, 08 Dec 2009 16:08:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=228#comment-50</guid>
		<description>Now that you have the GCD of two numbers, you can use that for an efficient equation to calculate the Least Common Multiple (LCM) or two numbers.

LCM(a, b) = &#124;a * b&#124;/ GCD(a, b)

Math is nifty.</description>
		<content:encoded><![CDATA[<p>Now that you have the GCD of two numbers, you can use that for an efficient equation to calculate the Least Common Multiple (LCM) or two numbers.</p>
<p>LCM(a, b) = |a * b|/ GCD(a, b)</p>
<p>Math is nifty.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rouli</title>
		<link>http://www.stealthcopter.com/blog/2009/12/python-highest-common-factor/comment-page-1/#comment-49</link>
		<dc:creator>rouli</dc:creator>
		<pubDate>Tue, 08 Dec 2009 13:57:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=228#comment-49</guid>
		<description>ah, it took me some time to understand how come the 145 in your example is not a multiply of 21, when both 252 and 105 are.
answer: it should be 147 :)</description>
		<content:encoded><![CDATA[<p>ah, it took me some time to understand how come the 145 in your example is not a multiply of 21, when both 252 and 105 are.<br />
answer: it should be 147 <img src='http://www.stealthcopter.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mat</title>
		<link>http://www.stealthcopter.com/blog/2009/12/python-highest-common-factor/comment-page-1/#comment-48</link>
		<dc:creator>mat</dc:creator>
		<pubDate>Tue, 08 Dec 2009 13:55:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=228#comment-48</guid>
		<description>@ Martin: I would have thought using subtraction would be quicker as modulo uses division however I tested it, and you are right!

@Juho: I did really want to implement it myself, as it&#039;s good to learn the method and maths behind functions. Plus thanks for spotting my error, thats what I get for doing it by hand!

@Bojan: Thanks, I think Martin beat you to it though.</description>
		<content:encoded><![CDATA[<p>@ Martin: I would have thought using subtraction would be quicker as modulo uses division however I tested it, and you are right!</p>
<p>@Juho: I did really want to implement it myself, as it&#8217;s good to learn the method and maths behind functions. Plus thanks for spotting my error, thats what I get for doing it by hand!</p>
<p>@Bojan: Thanks, I think Martin beat you to it though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bojan Resnik</title>
		<link>http://www.stealthcopter.com/blog/2009/12/python-highest-common-factor/comment-page-1/#comment-47</link>
		<dc:creator>Bojan Resnik</dc:creator>
		<pubDate>Tue, 08 Dec 2009 13:46:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=228#comment-47</guid>
		<description>This is perhaps more commonly known as &quot;greatest common divisor&quot;, or gcd. 
Euclid&#039;s algorithm can be recursively defined as:

    def gcd(a, b):
        return a if b == 0 else gcd(b, a % b)

In your code, you are basically using subtraction to calculate a % b.

A bit more elegant iterative implementation in Python, using  the modulo operator, would be:

    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a</description>
		<content:encoded><![CDATA[<p>This is perhaps more commonly known as &#8220;greatest common divisor&#8221;, or gcd.<br />
Euclid&#8217;s algorithm can be recursively defined as:</p>
<p>    def gcd(a, b):<br />
        return a if b == 0 else gcd(b, a % b)</p>
<p>In your code, you are basically using subtraction to calculate a % b.</p>
<p>A bit more elegant iterative implementation in Python, using  the modulo operator, would be:</p>
<p>    def gcd(a, b):<br />
        while b:<br />
            a, b = b, a % b<br />
        return a</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Juho Vepsäläinen</title>
		<link>http://www.stealthcopter.com/blog/2009/12/python-highest-common-factor/comment-page-1/#comment-46</link>
		<dc:creator>Juho Vepsäläinen</dc:creator>
		<pubDate>Tue, 08 Dec 2009 13:42:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=228#comment-46</guid>
		<description>You can find gcd in the fractions module (http://docs.python.org/library/fractions.html#fractions.gcd). No need to implement one yourself unless you really want to. :)

By the way 252-105 equals 147, not 145.</description>
		<content:encoded><![CDATA[<p>You can find gcd in the fractions module (<a href="http://docs.python.org/library/fractions.html#fractions.gcd" rel="nofollow">http://docs.python.org/library/fractions.html#fractions.gcd</a>). No need to implement one yourself unless you really want to. <img src='http://www.stealthcopter.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>By the way 252-105 equals 147, not 145.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://www.stealthcopter.com/blog/2009/12/python-highest-common-factor/comment-page-1/#comment-45</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Tue, 08 Dec 2009 13:41:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.stealthcopter.com/blog/?p=228#comment-45</guid>
		<description>It&#039;s more efficient to use the modulo (%) operator:

def gcd(a,b):
while b: a, b = b, a%b
return a</description>
		<content:encoded><![CDATA[<p>It&#8217;s more efficient to use the modulo (%) operator:</p>
<p>def gcd(a,b):<br />
while b: a, b = b, a%b<br />
return a</p>
]]></content:encoded>
	</item>
</channel>
</rss>
