CData Structures

Ackermann Function

Ackermann Function is the simplest example of a well defined total function which is compatible but not primitive recursive. It grows faster than an exponential function.

/* Ackermann Function */

int count = 0, indent = 0;

int ackermann(int x, int y)
	if(x<0 || y<0) return -1;
	if(x==0)  return y+1;
	if(y==0) return ackermann(x-1,1);
	return ackermann(x-1,ackermann(x,y-1));

int main()
	int x,y;
        printf("Enter values for x and y : ");
        printf("Result is %d\n",ackermann(x,y));
	printf("\nFunction called %d times.\n",count);


Rabins Sharma Lamichhane

Rabins Sharma Lamichhane is the owner of RabinsXP who is constantly working for increasing the Internet of Things (IoT) in Nepal. He also builds android apps and crafts beautiful websites. He is also working with various social services. The main aim of Lamichhane is to digitally empower the citizens of Nepal and make the world spiritually sound better both in terms of technology and personal development. Rabins is also the first initiator of Digital Nepal.

Leave a Reply

Your email address will not be published.

Back to top button

Adblock Detected

Please disable Adblock to have a smooth experience.