在运行在Node.js上的科学包中,我需要执行用户提供的数学表达式,如"sin(2*PI*x)“。目前,其实现方式类似于: // from input: s = "1+Math.sin(2*Math.PI*x)";// regexp to verify "s" doesn't containsdangerous characters as '";val f = new
我知道Math.sin()可以工作,但我需要使用factorial(int)自己实现它,我已经有了一个阶乘方法,下面是我的sin方法,但我无法得到与Math.sin()相同的结果 return 1; return n * factorial(n - 1);
public static double sin