title: Little coding challenge (Fermat’s Last Theorem)
body: <p>I am trying to learn Java; here is the exercise I am struggling with:</p>
  <blockquote>
  <p>Fermat’s Last Theorem says that there are no integers a, b, and c such that a^n + b^n = c^n except in the case when n = 2.</p>
  <p>Write a method named <code>checkFermat</code> that takes four integers as parameters— a, b, c and n—and that checks to see if Fermat’s theorem holds. If n is greater than 2 and it turns out to be true that a^n + b^n = c^n, the program should print “Holy smokes, Fermat was wrong!” Otherwise the program should print “No, that doesn’t work.”</p>
  <p>You should assume that there is a method named <code>raiseToPow</code> that takes two integers as arguments and that raises the first argument to the power of the second. For example:
  <code>int x = raiseToPow(2, 3);</code>
  would assign the value 8 to x, because 2^3 = 8.</p>
  </blockquote>
  <p>I have encountered several problems, for example I can't seem to use <code>Math.Pow(a, n)</code> with an <code>int</code>, only with a <code>double</code>. If you are interested, here is what I have so far, feel free to skip it and just write your own version of the program in the answers.</p>
  <p>(Please keep in mind I started this book only a few days back.)</p>
  <pre><code>    package fermat.s_last_theorem;
      import java.lang.Math;
      import java.util.Scanner;
  
      public class FermatS_Last_Theorem {
  
  
      public static void main(String[] args) {
  
      Scanner s = new Scanner (System.in);
      System.out.println(&quot;Inster First Number&quot;);
      double frst = s.nextDouble();
      System.out.println(&quot;Insert Second Number&quot;);
      double scnd = s.nextDouble();
   
      System.out.println(&quot;Insert Exponent&quot;);
      double expo = s.nextDouble();
  
  
      double v =  FLaw(frst,scnd,expo);
      double k = FLawRes(v, expo);
  
      System.out.println(&quot;The answer is &quot; + v);
      System.out.println(&quot;Your answer rooted by your exponent is &quot; + k);
      Law(v, Pow(k, expo));
    
      
      }
  
      public static double Pow(double a, double b) {
      double res = Math.pow (a, b);
      return (res);
      }
  
      public static double FLaw(double frst, double scnd, double expo) {
      double D1 = Pow(frst, expo);
      double D2 = Pow(scnd, expo);
     
      
      return (D1 + D2);
      
       }
    
       public static double FLawRes(double res, double base) {
       
       double D3 = Pow(res, 1/base);
       return D3;
        }
       
       public static void Law(double v, double k) {
         if (v==k) {
       System.out.println(&quot;Pythagora works.&quot;);
        } else {
       System.out.println(&quot;Pythagora doesnt work&quot;);
      }
     }
   }
  </code></pre>
  <p>The main problem is that I am not exactly sure how to answer the question the exercise asks, and the program listed above does not work as it should.</p>