<?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: Follow-up: Graham&#8217;s Number</title>
	<atom:link href="http://mathfactor.uark.edu/2007/04/13/follow-up-grahams-number/feed/" rel="self" type="application/rss+xml" />
	<link>http://mathfactor.uark.edu/2007/04/13/follow-up-grahams-number/</link>
	<description>The Math Factor Podcast Site</description>
	<pubDate>Fri, 25 Jul 2008 00:15:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: nklein</title>
		<link>http://mathfactor.uark.edu/2007/04/13/follow-up-grahams-number/#comment-51</link>
		<dc:creator>nklein</dc:creator>
		<pubDate>Fri, 13 Apr 2007 14:51:10 +0000</pubDate>
		<guid isPermaLink="false">http://mathfactor.uark.edu/2007/04/13/follow-up-grahams-number/#comment-51</guid>
		<description>Here are some snippets of Smalltalk code that one could add to the Integer class to compute the numbers in the Graham number sequence.  And, since Smalltalk already uses arbitrary-precision integers, you should be down the road:

graham
    self &#60; 1
        ifTrue: [ self error: 'Only supports positive graham indexes.' ].
    self =  1
        ifTrue: [ ^ 3 arrow: 3 arrowCount: 4. ].
    ^ 3 arrow: 3 arrowCount: ( ( self-1 ) graham ).

and then the arrow notation method:

arrow: power arrowCount: count
    power &#60; 0
        ifTrue: [ self error: 'Negative power is a problem.'. ].
    count &#60; 1
        ifTrue: [ self error: 'Must have at least one arrow.'. ].
    power = 0
        ifTrue: [ ^ 1. ].
    count = 1
        ifTrue: [ ^ self * ( self arrow: (power-1) arrowCount: count ). ].
    ^ self arrow: ( self arrow: (power-1) arrowCount: count ) arrowCount: (count-1).

So, to get the first graham number, one would do: &lt;code&gt;1 graham&lt;/code&gt;.  However, you best be able to interrupt it, because even the first number in the series is immense.
Anyhow, that's 16 lines of code... 6 of which are error checking.</description>
		<content:encoded><![CDATA[<p>Here are some snippets of Smalltalk code that one could add to the Integer class to compute the numbers in the Graham number sequence.  And, since Smalltalk already uses arbitrary-precision integers, you should be down the road:</p>
<p>graham<br />
    self &lt; 1<br />
        ifTrue: [ self error: 'Only supports positive graham indexes.' ].<br />
    self =  1<br />
        ifTrue: [ ^ 3 arrow: 3 arrowCount: 4. ].<br />
    ^ 3 arrow: 3 arrowCount: ( ( self-1 ) graham ).</p>
<p>and then the arrow notation method:</p>
<p>arrow: power arrowCount: count<br />
    power &lt; 0<br />
        ifTrue: [ self error: 'Negative power is a problem.'. ].<br />
    count &lt; 1<br />
        ifTrue: [ self error: 'Must have at least one arrow.'. ].<br />
    power = 0<br />
        ifTrue: [ ^ 1. ].<br />
    count = 1<br />
        ifTrue: [ ^ self * ( self arrow: (power-1) arrowCount: count ). ].<br />
    ^ self arrow: ( self arrow: (power-1) arrowCount: count ) arrowCount: (count-1).</p>
<p>So, to get the first graham number, one would do: <code>1 graham</code>.  However, you best be able to interrupt it, because even the first number in the series is immense.<br />
Anyhow, that&#8217;s 16 lines of code&#8230; 6 of which are error checking.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rmjarvis</title>
		<link>http://mathfactor.uark.edu/2007/04/13/follow-up-grahams-number/#comment-50</link>
		<dc:creator>rmjarvis</dc:creator>
		<pubDate>Fri, 13 Apr 2007 14:43:25 +0000</pubDate>
		<guid isPermaLink="false">http://mathfactor.uark.edu/2007/04/13/follow-up-grahams-number/#comment-50</guid>
		<description>Here is a C progam that would print out Graham's number if it could store infinitely large integers:

#include 

int f(int a, int b, int c)
{
  int i,x;
  if(c==1) for(x=1;b&#62;0;--b) x *= a;
  else {
    x = f(a,b,--c);
    for(i=c;i&#62;0;--i) x = f(a,x,c);
  }
  return x;
}

int g(int n)
{
  return n==1 ? f(3,3,4) : f(3,3,g(n-1));
}

int main()
{
  return printf("%d\n",g(64));
}

Basically, g(n) is the nth number in Graham's sequence, for which g(64) is Graham's number.  f(a,b,c) is a^^^...^^^b where there are c ^'s in there.

It's probably a bit longer than the Fortran version, since C doesn't have any native integer exponent function, so I had to write my own (the c==1 case at the start of the f function.)</description>
		<content:encoded><![CDATA[<p>Here is a C progam that would print out Graham&#8217;s number if it could store infinitely large integers:</p>
<p>#include </p>
<p>int f(int a, int b, int c)<br />
{<br />
  int i,x;<br />
  if(c==1) for(x=1;b&gt;0;&#8211;b) x *= a;<br />
  else {<br />
    x = f(a,b,&#8211;c);<br />
    for(i=c;i&gt;0;&#8211;i) x = f(a,x,c);<br />
  }<br />
  return x;<br />
}</p>
<p>int g(int n)<br />
{<br />
  return n==1 ? f(3,3,4) : f(3,3,g(n-1));<br />
}</p>
<p>int main()<br />
{<br />
  return printf(&#8221;%d\n&#8221;,g(64));<br />
}</p>
<p>Basically, g(n) is the nth number in Graham&#8217;s sequence, for which g(64) is Graham&#8217;s number.  f(a,b,c) is a^^^&#8230;^^^b where there are c ^&#8217;s in there.</p>
<p>It&#8217;s probably a bit longer than the Fortran version, since C doesn&#8217;t have any native integer exponent function, so I had to write my own (the c==1 case at the start of the f function.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
