• Create Account

### #Actualsooner123

Posted 06 December 2012 - 02:33 PM

UPDATE: I figured it out. If you're interested, here was my problem and the solution is below.

In trying to write a recursive function that returns the fastest growing hierarchy (a really fast growing function).

Here is the definition:

Base function f0: f0(n) = n+1

Next function f(a+1): f(a+1)(n) = fan(n)

Functional powers: f(a+1)(n) = f(fa(n)) where f0(n) = n

#include <iostream>

using namespace std;

int hf(int, int);

int f(int x, int power, int functionalBase)
{
if (power==1) return hf(x, functionalBase);
else return f(f(x, power-1, functionalBase),1, functionalBase);
}

int hf(int x, int functionalBase)
{
if (functionalBase==0) return x+1;
else return f(x,x,functionalBase-1);
}

int main()
{
cout << f(2, 2, 2);
}

### #4sooner123

Posted 06 December 2012 - 02:32 PM

UPDATE: I figured it out. If you're interested, here was my problem and the solution is below.

In trying to write a recursive function that returns the fastest growing hierarchy (a really fast growing function).

Here is the definition:

Base function f0: f0(n) = n+1

Next function f(a+1): f(a+1)(n) = fan(n)

Functional powers: f(a+1)(n) = f(fa(n)) where f0(n) = n

[source lang="cpp"]#include <iostream>using namespace std;int hf(int, int);int f(int x, int power, int functionalBase){ if (power==1) return hf(x, functionalBase); else return f(f(x, power-1, functionalBase),1, functionalBase);}int hf(int x, int functionalBase){ if (functionalBase==0) return x+1; else return f(x,x,functionalBase-1);}int main(){ cout << f(2, 2, 2);}[/source]

### #3sooner123

Posted 06 December 2012 - 02:15 PM

In trying to write a recursive function that returns the fastest growing hierarchy (a really fast growing function), I've run into a problem: I'm not sure recursion is built to handle the syntax involved.

Here is the formula:

Base function f0: f0(n) = n+1

Next function f(a+1): f(a+1)(n) = fan(n)

Functional powers: f(a+1)(n) = f(fa(n)) where f0(n) = n

So far my attempts to write a recursive function that simulates this have run into problems.

So I tried to simply do the functional power part:

f(a+1)(n) = f(fa(n))

And found even this difficult:

[source lang="cpp"]int f(int x, int power){ if (power==1) return x+1; else return f(f(x, power-1), 1);}[/source]

Of course I can see why this fails, but it just seems like a recursive function with more than one argument runs into this type of issue where it's not really expressible as a recursive function. Or I'm missing something fundamental here.

### #2sooner123

Posted 06 December 2012 - 02:10 PM

In trying to write a recursive function that returns the fastest growing hierarchy (a really fast growing function), I've run into a problem: I'm not sure recursion is built to handle the syntax involved.

Here is the formula:

Base function f0: f0(n) = n+1

Next function f(a+1): f(a+1)(n) = fan(n)

Functional powers: f(a+1)(n) = f(fa(n)) where f0(n) = n

So far my attempts to write a recursive function that simulates this have run into problems.

So I tried to simply do the functional power part:

f(a+1)(n) = f(fa(n))

And found even this difficult:

[source lang="cpp"]int f(int x, int power){ if (power==1) return x+1; else return f(f(x, power-1), 0);}[/source]

Of course I can see why this fails, but it just seems like a recursive function with more than one argument runs into this type of issue where it's not really expressible as a recursive function. Or I'm missing something fundamental here.

### #1sooner123

Posted 06 December 2012 - 02:05 PM

In trying to write a recursive function that returns the fastest growing hierarchy (a really fast growing function), I've run into a problem: I'm not sure recursion is built to handle the syntax involved.

Here is the formula:

Base function f0: f0(n) = n+1

Next function f(a+1): f(a+1)(n) = fan(n)

Functional powers: f(a+1)(n) = f(fa(n)) where f0(n) = n

So far my attempts to write a recursive function that simulates this have run into problems.

So I tried to simply do the functional power part:

f(a+1)(n) = f(fa(n))

And found even this difficult:

[source lang="cpp"]int f(int x, int power){ if (power==0) return x; else return f(f(x, power-1), 0);}[/source]

Of course I can see why this fails, but it just seems like a recursive function with more than one argument runs into this type of issue where it's not really expressible as a recursive function. Or I'm missing something fundamental here.

PARTNERS