Interesting approach, but I from testing just now it seems testing factorials up to sqrt(number) isn’t enough.

I took the liberty of changing it a bit:

```
void setup() {
size(200, 600);
fill(0);
for(int number=2; number < 50; number++){
if(isPrimeNumber(number)){
fill(200,0,0);
text(number+" is a prime number",15,12*number);
} else {
fill(0);
text(number+ " is not a prime number",15,12*number);
}
}
}
boolean isPrimeNumber(int number) {
boolean test = true;
for(int i=2; i<number; i++){
if(number%i == 0){
test = false;
break; // skips rest of loop
}
}
return test;
}
```

There’s also a Java library BigIntegers that have built-in methods for primes (with some probability it seems):

```
/** Test of really big integers
http://www.tutorialspoint.com/java/math/java_math_biginteger.htm
Description
The java.math.BigInteger.nextProbablePrime() returns the first integer greater than this BigInteger that is probably prime.
The probability that the number returned by this method is composite does not exceed 2^-100.
This method will never skip over a prime when searching: if it returns p, there is no prime q such that this < q < p.
Declaration
Following is the declaration for java.math.BigInteger.nextProbablePrime() method
public BigInteger nextProbablePrime()
Parameters
NA
Return Value
This method returns the first integer greater than this BigInteger that is probably prime.
Exception
ArithmeticException - if this < 0
Example
The following example shows the usage of math.BigInteger.nextProbablePrime() method
*/
//import java.math.*;
import java.math.BigInteger;
//import java.util.*;
// create 2 BigInteger objects
BigInteger bi1, bi2;
bi1 = new BigInteger("20148832325468531");
// assign nextProbablePrime value of bi1 to bi2
bi2 = bi1.nextProbablePrime();
String str = "Next probable prime after " + bi1 +" is " +bi2;
println( str );
```