title: Iterative formula for finding prime numbers in java
body: <p>I cannot get my code to work for the life of me. I have been fighting with it for the past 13 hours. I am supposed to use a function GetPrime, which is an array, to call a boolean function IsPrime to look up all numbers and return the ones that are prime. We can use either iterative or recursive formulas, but it is suggested that we use iterative. This is the code that I have so far:</p>
  
  <pre><code>import java.util.*;
  
  public class util3_2 {
  
  
  public static boolean IsPrime(int p) {
  
  if (p % 2 == 0) return false;
  
  for(int i = 3; i * i &lt;= p; i += 2) {
      if(p % i == 0)
      return false;
  }
  return true;
  }  
  
  public static int[] GetPrimes(int n)   {
  
  for (int i = 1; i &lt;= n; i ++)
  {
     int[] array = new int [n];
  
      IsPrime(n);
  
  }
  </code></pre>
  
  <p>We are using java. Some of the functions are giving me a very hard time, not to mention, it does not want brackets at the end, like a baby fighting to keep food out of his or her mouth. I hope someone can help. Thanks.</p>