Improve the performance of the following code:
var test = {
    f: function(n) {
        if (n === 0) {
            return 0;
        }
        if (n === 1) {
            return 1;
        }
        else {
            return f(n - 1) +
                f(n - 2);
        }
    }
};
Comments (2)