到目前为止,这是我的方法:
public static int[] simplifyRadical(int number) {
int[] result = new int[2];
for (int i = 1; i < number / 2; i++) {
if ((i % number == 0)) {
//IS a factor of the number in the radical
}
}
return result;
}
我使用的格式是result[0] = number outside radicaland result[1] = number inside radical。到目前为止,我的方法得到了所有的因子number(即部首中的初始 UNSIMPLFIED 数)。那么如何将初始值number除以完美平方,得到平方根并将其乘以我的result[0]变量。然后继续循环,直到找不到完美的正方形。很抱歉,如果这个问题读起来令人困惑,写起来肯定令人困惑。如果您需要任何澄清,请在下面发表评论。
更新:
所以在数学上我正在变成:sqrt(50)因为5 sqrt(2)和sqrt(50) = sqrt(25 * 2)25 是 5 的完美平方,因此:5 sqrt(2)形成。