Christian271

12-06-2008, 03:15 AM

Here's a function I made for finding the root of most whole numbers.

function root(Num,Root) {

var out = Root + "\u221A" + Num + " Irrational";

for(i=Num;i>=0;i--) {

if(Math.pow(i,Root)==Num) {out = i;}

}

return out;

} Num is the number you're finding the root of, and Root is the root you're finding. So root(4,2) would return 2. If the root is irrational then the function will return "Root√Num Irrational" (e.g. root(4,3) would return "3√4 Irrational").

function root(Num,Root) {

var out = Root + "\u221A" + Num + " Irrational";

for(i=Num;i>=0;i--) {

if(Math.pow(i,Root)==Num) {out = i;}

}

return out;

} Num is the number you're finding the root of, and Root is the root you're finding. So root(4,2) would return 2. If the root is irrational then the function will return "Root√Num Irrational" (e.g. root(4,3) would return "3√4 Irrational").