function Root(angle) { with (Math) { this.r = cos(angle); this.i = sin(angle) } } Root.prototype.toFixed = function(p) { return this.r.toFixed(p) + (this.i >= 0 ? '+' : '') + this.i.toFixed(p) + 'i' } function roots(n) { var rs = [], teta = 2*Math.PI/n for (var angle=0, i=0; i') }