خرید بک لینک

Vote count: 0

I wrote a code that needs to check if a theory that says that the following formula can never be true unless n=2 a^n + b^n = c^n. The program do tell me at the end "Meh, Fermet was right" marking the end of the program, but afterwards it throws allot of lines of exception. for my second question is, how can I make this code shorter and more efficient? I know for sure that what I have created here is a bad overloaded code but I don't know how to improve it.

This is the code -

public class CheckFermets {

public static void main(String[] args) {
    int a=2;
    int b=2;
    int c=2;
    int n=3;
    int round = 2;
    CheckupA (a,b,c,n,round);

}
public static void CheckupA (int a, int b, int c, int n ,int round)
{
    if (Math.pow(a,n)+Math.pow(b,n)==Math.pow(c, n))
    {
        System.out.println("HOLYSHIT FERMET WAS WRONG!!");
    }
    else
    {
        if (a==9)
        {
            a=round+1;
            CheckupB (a,b,c,n, round);

        }
        else
        {
        a++;
        CheckupA (a,b,c,n, round);
        }
    }
}
public static void CheckupB (int a, int b, int c, int n,int round)
{
if (Math.pow(a,n)+Math.pow(b,n)==Math.pow(c, n))
{
    System.out.println("HOLYSHIT FERMET WAS WRONG!!");
}
else
{
    if (b==9)
    {
        b=round+1;
        CheckupC (a,b,c,n, round);

    }
    else
    {
    b++;
    CheckupB (a,b,c,n, round);
    }
}
}
public static void CheckupC (int a, int b, int c, int n,int round)
{
if (Math.pow(a,n)+Math.pow(b,n)==Math.pow(c, n))
{
    System.out.println("HOLYSHIT FERMET WAS WRONG!!");
}
else
{
    if (c==9)
    {
        c=round+1;
        round++;
        CheckIfFinished (n);
        checkIfIncreaseN (a,b,c,round, n);
        CheckupA (a,b,c,n, round);

    }
    else
    {
    c++;
    CheckupC (a,b,c,n, round);
    }
}
}
public static void checkIfIncreaseN(int a, int b, int c, int round, int n)
{
    if(round==9)
    {
        round = 2;
        a=2;
        b=2;
        c=2;
        n++;
        CheckupA (a,b,c,n,round);

    }
}
public static void CheckIfFinished (int n)
{
    if (n==9)
    {
        System.out.println("Meh, Fermet was right");
        retu;
    }
}

}

asked 17 secs ago

برچسب: نویسنده: استخدام کار تاريخ: شنبه 5 تير 1395 ساعت: 16:19

صفحه بندی