我正在尝试使用费马的最后一个方程制作一个递归分析程序,但它不断返回我不明白的方程是错误的?
public class fermatdata
{
public static void data(int a, int b, int c, int n)
{
if ((Math.pow(a, n)) + (Math.pow(b, n)) == (Math.pow(c, n)))
{
System.out.println("Holy smokes, Fermat was wrong!");
return;
}
else
{
data(a-1, b-1, c-1, n-1);
if (n < 2)
{
return;
}
else
{
data(a-1, b-1, c-1, n-1);
}
}
System.out.println("No, that doesn't work. Fermat was right");
}
public static void main(String[] args)
{
System.out.println("Fermat's last theorem stated that the formula a^n + b^n = c^n while n>2 and all of the numbers are integers will never be correct. Here I am going to do an analysis with all the numbers starting at 100,000 and count backwords to 3");
data(100000, 100000, 100000, 100000);
}
}