Ackermann's Function in C++

Ackermann's function is a recursive mathematical algorithm that can be used to test how well a computer performs recursion. Write a function A(m,n) that solves Ackermann's function. Use the following logic in your function:

If m=0 then return n+1
If n=0 then return A(m-1,1)
Otherwise, return A(m-1, A(m, n-1))

Test your function in a driver program that displays the following values:

A(0,0) A(0,1) A(1,1) A(1,2) A(1,3) A(2,2) A(3,2)

This is my code:

#include <iostream>
using namespace std;

int A(int, int);

int main()
{
int m=NULL, n=0, count=0;

while(count<=7)
{
cout<<A(m,n);

count++;
};

return 0;
}
int A(int m,int n)
{ if(n==1 && m==0)
{
m+=1;
}

if (m==0)
{
cout<<"A("<<m<<","<<n<<")";
return n+1;
}
else if (n==0)
{
cout<<"A("<<m<<","<<n<<")";
return A(m-1,1);
}
else
{
cout<<"A("<<m<<","<<n<<")";
return A(m-1, A(m,n-1));
}
}

My output is:
A(0,0)1A(0,0)1A(0,0)1A(0,0)1A(0,0)1A(0,0)1A(0,0)1A(0,0)1Press any key to continu
e . . .

Wat am i doing wrong?

Ackermann function giving StackOverflowError

all, I have written a program to calculate numbers based on the Ackerman Function (http://en.wikipedia.org/wiki/Ackermann_function). The Ackermann Function generates very large numbers with very low input, aka 4,1 = 65533, 4,2 = (2^65536) − 3, etc. I'm trying to calculate 3,10 which should res ...

jQuery basic sort function

guys today I finally got around to using jQuery today and man do ilove it. wished that I had known about it before I started my lastproject. would have saved me a couple of months work.Ok well back to todayI needed to take a structure (table made of div's) and sort byalphabetic order once I got ...

jQuery hover function goes bezerk in loop

Consider the following example: http://enquest.eu/test.html ...I made a example where a submenu slides out when you go over it with the mouse.The problem I have with these animations is as follows.You go over the test menu it opens nicely. Then you go over mouseout the timeout goes and the menu clos ...

Jquery.css function poor performance

-- ...

jQuery Unable to bind click function in a dynamically created object?

i got a bit of a stumper for ya, trying to bind a function to the click event of each link in a dynamically generated list.i have a bunch of long content pages that we're breaking up into subpages, with a sidenav to navigate through them. the markup for each page is as follows:<div class= ...

Jquery.css function poor performance

<div>Hi,</div><div> </div><div>I'm performing css manipulation in my application, but the performance degrades considerably fast as more markup is added. I tracked the problem to the jQuery.css function, specifically for those cases where I'm setting the width and ...

jQuery How to bind a function only once

I have a group of checkboxes, and as long as any one of the boxes is checkedI need a function bound to a select list, but anytime none of the boxes arechecked I need the function unbound. What I have below binds and unbinds,but if I select lets say 4 checkboxes the function is bound and called 4time ...

jQuery How to bind a function only once

> I have a group of checkboxes, and as long as any one of> the boxes is checked I need a function bound to a select> list, but anytime none of the boxes are checked I need the> function unbound. What I have below binds and unbinds,> but if I select lets say 4 checkboxes the function i ...

jQuery forms plugin how to implement a preCallBack function to validate inputs

I would like to use the precallback function to check the inputs of the form heres my preCall function    function preContact()    {        // check name is not empty        if($("input#yrName").value ...

Function from jquery_auto

i find this fine Plugin:http://sputnik.pl/code/javascript/jquery_autocan i use the Auto-submitting SELECTs Function solo?not in the Plugin, i write this, works no:$(document).ready(function() {$('SELECT.Submit').bind('change', this.on_change);function change() {if (this.value) this.f ...

jQuery controling when function get executed

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 11 (filtered m ...

jQuery Why does $("body").resize(function(){ alert("hello"); }); does not trigger ?

does someone know why this does not work ? Or do i bind to wrong object? I want the function to be called when the browser changes window size.best regards,Truppe Steven ...

jQuery input.setAttribute is not a function

Hi,I'm using Jquery for a little Ajax I'm putting in a form. I'm no JS expertbut I can usually hack it so it works.The Jquery works for the stuff I'm using it for, but it seems to clash withthe drupal.js or something.Anyway, I get the following in firebug: input.setAttribute is not a ...

jQuery how to stop each iteration under each's function?

<div>for exzample:</div><div> </div><div>$("input[@type='text']").each(function(){if (this.value==""){alert("error");this.focus();break;}});</div><div> </div><div>but 'break;' won't stop the iteration of ea ...

jQuery how to stop each iteration under each's function?

> but 'break;' won't stop the iteration of each, what should i do?Return false inside the function and it will stop. That was added recentlybut the docs weren't updated to reflect it. ...

jQuery Function to enumerate the querystring?

Is there a jQuery function to enumerate the key/value pairs in aquerystring? I wasn't able to find one with the Visual jQuery websiteand instead of reinventing the wheel I thought I'd query the list.Thanks,Chris. ...

jQuery Function to enumerate the querystring?

On Wednesday, November 01, 2006 11:59 AM Klaus Hartl <> said: ...

jQuery Function to enumerate the querystring?

On Tuesday, October 31, 2006 10:46 AM Luke Lutman <> said: ...

jQuery Overlapping divs & toggleContent function

I'm having a problem in FF2 with the contents of a "toggled" div overlapping two divs below it.The problem (http://horticulture127.massey.ac.nz/dumpthis.htm) occurs when the [Glossary] link is clicked to reveal an input box for a glossary search.In IE6, two divs beneath are "pushe ...

jQuery Bug #262: "name.replace is not a function" in 1.0.3

> Can some more folks take a look at this and see if there's ...

jQuery dimensions.js breaks height function?

Please advise: I need to use dimensions.js for the offset function. However,since this file overwrites JQuery's height function, I can no longer setheights (-- i.e. $("p").height("20px"); --). Will the offset function workon all browsers if I strip out dimensions' height ...

jQuery [Beginner. Help] Javascript not function in the loaded content by AJAX

thanks, all :)now, I apply eval($("div#append_area script").html());after:$("div#append_area").append(data);it works.I have thought to use:$("div#append_area").load('/ajax_input',$("#input_form").fastSerialize(), function(data)// do stuff on laod});But ...

jQuery [Beginner. Help] Javascript not function in the loaded content by AJAX

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><META http-equiv=Content-Type content="text/html; charset=us-ascii"><META content="MSHTML 6.00.2900.2964" name=GENERATOR></HEAD><BODY><DIV dir=ltr align=left><FONT face= ...

Need help on first JQuery nested list function

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generato ...

Need help on first JQuery nested list function

<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 11 (filtered m ...

jQuery SOT: Function review please?

The coupon codes are freely offered on the website, quite prominentlyactually. If the person still doesn't use them then that's their loss.The price is calculated in the cart code so I'm not worried about that. Thisis more a check because some people are using the wrong code either onpur ...

jQuery SOT: Function review please?

Do you want to prevent someone with an order over $1500 from using thesave10 coupon code? Why not let them use it? They're leaving more money onthe table for you, so let them have the smaller discount.If I View Source I can get the coupon codes? :) I would do a hash on thecoupon code (a simple c ...

jQuery SOT: Function review please?

A client has a range of coupon codes that people can enter in the shoppingcart to receive a certain percentage off their order. It's based on theirsubtotal in a range from 0 - $6000. He says that sometimes people willlenter the max coupon code for a lower range order thinking that they'll ge ...

jQuery executing a function thickbox closes

all,I am trying to execute a function when thickbox gets closed.using the code below I can get the alert box to run:$("#TB_closeWindowButton").click(                        ...