0

Hey all,

In computer class as homework we're to create a code to find prime numbers between two values m and n without using an array (since we havn't learned about how to use them yet).

so far the code I have is:

```
public static void prime (int m, double n){
int prime = m;
while (prime <= n){
if(isPrime(prime)){
System.out.print(prime+", ");
}
prime ++;
}
}
public static boolean isPrime (int p){
for (int x = 2; x < p; x++){
if (p%x == 0){
return false;
}
}
return true;
}
```

This are the two methods - prime and isPrime - I created to find the prime numbers between the two numbers m and n. The program works fine, however if m = 10 and n = 10000, the program takes a very long time to print out all the prime numbers inbetween 10 and 10000. I would like to shorten this time. I assume this is because of the for loop inside the isPrime method. Hopefully someone will be able to help me here since I have been struggling with this problem for quite some time.

Thanks