Ejemplo n.º 1
0
  /**
   * Standard point of execution.
   *
   * @param args - not used
   */
  public static void main(String[] args) {

    Problem curProb = new PE0059();
    String result = curProb.getResult();

    IO.info("result for problem #" + curProb);
    IO.info(" is '" + result + "'");
    IO.infoln(" found in " + curProb.getRuntime(2) + " ms");
  }
Ejemplo n.º 2
0
  /**
   * Runs the algorithm of the "Sieve of Eratosthenes" and count every found prime factor. If the
   * 10001. is found, it is returned.
   *
   * @return the 100001. prime factor
   * @see Sieve#next()
   * @see <a href="http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes">Sieve of Eratosthenes @
   *     Wikipedia</a>
   */
  @Override
  public String solve() {

    while (sieve.hasNext() && cnt < 9999) {
      cnt++;
      IO.infoln(cnt + ". prime = " + sieve.next());
    }

    return IO.i2s(sieve.next());
  }