title: Method to find a factor of a number
body: <p>I am trying to write a simple program that takes a non-prime number and returns the first factor of it. I have to use a method to do this. I think that I am really close to the correct code, but I keep running into variable definition issues in my method. Here is my (currently incorrect) code:</p>
  
  <pre><code>public class testing {
      public static void main(String[] args) {
  
          int a;
  
          a = 42;
  
          System.out.println(factor(a));
  
      }
  
      //This method finds a factor of the non-prime number
      public static int factor(int m) {   
          for(int y=2 ; y &lt;= m/2 ; y++) {
              if(m%y==0) {
                  return y;
                  continue;
              }
          }
      return y;
      }
  }
  </code></pre>
  
  <p>Please let me know what's incorrect!</p>