something is wrong with my javascript calculator
<p>Something completely elusive to me is wrong with this code, and the code is completely useless.  I have no idea what.  help.</p>

<p><a href="http://jsfiddle.net/runizgozilla/jZtDp/15/" rel="nofollow">http://jsfiddle.net/runizgozilla/jZtDp/15/</a></p>

<p>I'm targeting td elements with an id for each button.  The script attaches event handler functions to each button and updates when they are pressed, but they don't work!  I don't know why.</p>

<p>the javascript:</p>

<pre><code>/* 

    Javascript calculator with HTML, Javascript, and JQuery.
              By: Josh Dorsey

*/

var number1 = 0;
var number2 = 0;
var oneset = false;
var twoset = false;
var operation = "addition";
var operationSymbol = "+";
var result = 0;
var printResult = false;
var f = new Array();
var calculating = false;
var writing = 1;

function factorial(n) {
    if (n === 0 || n == 1) return 1;
    if (f[n] &gt; 0) return f[n];
    else return f[n] == factorial(n - 1) * n;
}

// Determines how to display the information currently saved, and does so when invoked.

function updateOutput() {
    if (calculate) {
        if (oneset &amp;&amp; !twoset) {
            if (operation == "square" || operation == "factorize") {
                $("#operation").text(number1 + operationSymbol);
                $("#result").text(calculate(operation, number1, number2));
            } else {
                $("#operation").text("");
                $("#result").text("");
            }
        }
        if (twoset) {
            $("#operation").text(number1 + " " + operationSymbol + " " + number2);
            $("#result").text(calculate(operation, number1, number2));
        }
    } else {
        if(oneset &amp;&amp; !twoset){
            $("#output").text(number1 + " " + operationSymbol);
        } else {
            $("#output").text(number1 + " " + operationSymbol + " " + number2);
        }
    }
}

//  Actual calculations are done in the calculate() function.

function calculate(operation, num1, num2) {
    result = 0;
    switch (operation) {
        case "addition":
            result = num1 + num2;
            return result;
        case "subtraction":
            result = num1 - num2;
            return result;
        case "multiplication":
            result = num1 * num2;
            return result;
        case "division":
            result = num1 / num2;
            return result;
        case "factorial":
            result = factorial(num2);
            return result;
        case "square":
            result = num1 * num1;
    }
}

function equal() {
    calculating = true;
    updateOutput();
    calculating = false;
}

$("#equals").click(equal());

//  Write the numbers to the appropriate variables based on the 
//  "writing" variable, which decides when a value is done being entered.

$("#0").click(function(){});
$("#1").click(function(){
    if(writing == 1){
        number1 = number1 * 10 + 1;
        updateOutput();
    } else {
        number2 = number2 * 10 + 1;
        updateOutput();
    }
});
$("#2").click(function(){
    if(writing == 1){
        number1 = number1 * 10 + 2;
        updateOutput();
    } else {
        number2 = number2 * 10 + 2;
        updateOutput();
    }
});
$("#3").click(function(){
    if(writing == 1){
        number1 = number1 * 10 + 3;
        updateOutput();
    } else {
        number2 = number2 * 10 + 3;
        updateOutput();
    }
});
$("#4").click(function(){
    if(writing == 1){
        number1 = number1 * 10 + 4;
        updateOutput();
    } else {
        number2 = number2 * 10 + 4;
        updateOutput();
    }
});
$("#5").click(function(){
    if(writing == 1){
        number1 = number1 * 10 + 5;
        updateOutput();
    } else {
        number2 = number2 * 10 + 5;
        updateOutput();
    }
});
$("#6").click(function(){
    if(writing == 1){
        number1 = number1 * 10 + 6;
        updateOutput();
    } else {
        number2 = number2 * 10 + 6;
        updateOutput();
    }
});
$("#7").click(function(){
    if(writing == 1){
        number1 = number1 * 10 + 7;
        updateOutput();
    } else {
        number2 = number2 * 10 + 7;
        updateOutput();
    }
});
$("#8").click(function(){
    if(writing == 1){
        number1 = number1 * 10 + 8;
        updateOutput();
    } else {
        number2 = number2 * 10 + 8;
        updateOutput();
    }
});
$("#9").click(function(){
    if(writing == 1){
        number1 = number1 * 10 + 9;
        updateOutput();
    } else {
        number2 = number2 * 10 + 9;
        updateOutput();
    }
});

//  Operand click listeners.
/*
  Operand IDs
  - add
  - subtract
  - multiply
  - divide
  - square
  - factorize
*/

$("#add").click(function(){
    if(writing == 1){
        writing = 2;
    }
    operation = "addition";
    operationSymbol = "+";
});
$("#subtract").click(function(){
    if(writing == 1){
        writing = 2;
    }
    operation = "subtraction";
    operationSymbol = "-";
});
$("#multiply").click(function(){
    if(writing == 1){
        writing = 2;
    }
    operation = "multiplication";
    operationSymbol = "*";
});
$("#divide").click(function(){
    if(writing == 1){
        writing = 2;
    }
    operation = "division";
    operationSymbol = "/";
});
$("#square").click(function(){
    if(writing == 1){
        writing = 2;
    }
    operation = "square";
    operationSymbol = "^2";
});
$("#factorize").click(function(){
    if(writing == 1){
        writing = 2;
    }
    operation = "factorial";
    operationSymbol = "!";
});
</code></pre>
