## Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

### Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.  # Project Euler Problem 10 JAVA - Bug

Not sure why I don't get the right answer here...

```public class Main {

public static final int num = 2000000;

public static void main(String[] args) {
int sum = 0;
for (int i = 0; i < num; i++) {
if(isPrime(i)) {
sum += i;
}
}

System.out.println("Sum: " + sum);

}

public static boolean isPrime(int n) {
if (n <= 1) {
return false;
}
for (int i = 2; i < Math.sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}

}
``` Working on sums of primes under 10. Starting small so numbers are manageable.

```public class Main {

public static final int num = 10;

public static void main(String[] args) {
int sum = 0;
for (int i = 0; i < num; i++) {
if(isPrime(i)) {
sum += i;
System.out.println("Prime:"+i);
}
}
System.out.println("Sum: " + sum);
}

public static boolean isPrime(int n) {
if (n <= 1) {
return false;
}
for (int i = 2; i < Math.sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
```

produces

```Prime:2
Prime:3
Prime:4
Prime:5
Prime:7
Prime:9
Sum: 30
```

I'm guessing

```public class Main {

public static final int num = 10;

public static void main(String[] args) {
int sum = 0;
for (int i = 0; i < num; i++) {
if(isPrime(i)) {
sum += i;
System.out.println("Prime:"+i);
}
}
System.out.println("Sum: " + sum);
}

public static boolean isPrime(int n) {
if (n <= 1) {
return false;
}
for (int i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
```