Code dump:function factor(n) {    function count(a) {        if (a.length == 0) {            return [];        } else {            var x = a.pop();            var l = count(a);            if (l[x] == undefined) {                l[x] = 0;            }            l[x]++;            return l;        }    }    function decomp(comp, fac) {        if (comp == 1) {            return [];        }        if (fac == 1) {            return [ comp ];        }        if (comp % fac == 0) {            return decomp(fac, fac - 1).concat(decomp(comp / fac, fac));        } else {            return decomp(comp, fac - 1);        }    }    return count(decomp(n, n)).map(function(a, b) {        return [ b, a ];    }).filter(function(a, b) {        return a[1];    }).map(function(a, b) {        return  + a[0] + ^ + a[1];    }).reduce(function(a, b) {        return a +  *  + b;    }).replace(^1, );}It's mainly because I've been into functional programming lately that I tried a loopless, stateless, functional algorithm; I know that this example is absolutely facetious and that no one would do this in real life. That said, are there ways I can make this:More efficient (e.g. less data),More concise (which keeping the cool functional aspect), orMore functional (in a good way) in paradigm?
Factoring Integers the fun way
javascript;algorithm;recursion;functional programming;rational numbers