Hello everybody!

I've been working on trial division loop problem and I hit a dead end

Before I write about how I attempted to the problem before coming here, I have to show you guys the problem.

THE PROBLEM-------------------------------

Find and print out the eight prime integers between 99,900 and 99,999 using trial division (testing divisibility by possible factors). Write two nested loops: The outer loop will iterate over the 100 numbers being tested for primeness; the inner loop will check potential factors, from 2 up to the square root of the large dividend number (don't worry about which ones are or aren't prime). Use the modulo operator % to test for divisibility, and stop testing factors — cut the inner loop short — after finding one. Example: the first dividend to test is 99,900; its potential factors run from 2 to 316. Since ( 99900 % 2 == 0 ), it is not prime, so do not check factors 3 and higher, but exit the inner loop and go directly to processing 99,901.

--------------------------------------------

SO TO TACKLE THIS PROBLEM.

Thanks for jps for the advice on writing out the steps.

1. I set the min value to 99900 and the max value to 99999 and my outer loop will iterate for 100 times.

2. The outer loop also has to test for primeness so I wrote an "if statement" to check for divisibility and if it is divisible by 2, a continue statement to end

that loop and to continue to the next one.

3. I wrote the inner loop to test for factors by trial division.

4. Loop goes wrong and won't print the prime numbers.. anybody have any ideas on whats wrong?

Heres my loop:

/* This program is designed to find and print out the eight prime integers between 99,900 and 99,999 using trial division*/ // instructions = write two nested loops // the outer loop will iterate over the 100 numbers being tested for primeness // the inner loop will check potential factors from 2 up to the square root of the large dividend numbers. // This program will use % to test for divisibility public class assignment7 { public static void main(String args[]) { // The two numbers int divider = 2; int min; int max = 99999; // Loop iteration of the 100 numbers for(min = 99900; min < max; min++) { for(divider = 2; divider <= Math.sqrt(min); divider++) { if(min % divider == 0) { continue; } System.out.println("Prime: "+ min); } } } }

any ideas or advice?