Exercise 4 6 (Fermat)
public class fermat    
{
 
    public static void checkFermat(int a, int b, int c, int n) {
        if(n > 2 && Math.pow(a,n) + Math.pow(b,n) == raiseToPow(c,n)){
            System.out.println("Holy smokes, Fermat was wrong!");
        }else{
            System.out.println("No, that doesn’t work");
        }
    }
 
    public static void main(String [] args) {
        //code
        int a = 3;
        int b = 4;
        int c = 6;
        int n = 10;
        checkFermat(a,b,c,n);
    }
}

voltar

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.