Sign in to follow this  
sooner123

Fastest Growing Hierarchy

Recommended Posts

sooner123    269
[i][b]UPDATE: I figured it out. If you're interested, here was my problem and the solution is below.[/b][/i]

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

Here is the definition:

[b]Base function f[sub]0[/sub]:[/b] [b]f[sub]0[/sub](n) = n+1[/b]

[b]Next function f[sub](a+1)[/sub]:[/b] [b]f[sub](a+1)[/sub](n) = f[sub]a[/sub][sup]n[/sup](n)[/b]

[b]Functional powers:[/b] [b]f[sup](a+1)[/sup](n) = f(f[sup]a[/sup](n)) where f[sup]0[/sup](n) = n[/b]

[code]#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);
}[/code] Edited by sooner123

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this