I think I finally have the logic worked out for first thousand primes puzzle that i have been puzzling over ever since I found MIT OPEN COURSEWARE ... I think there may be some bugs but overall the logic should work as far as I can tell. Why is there a sytax error in the second line of the while loop asking for a semicolon when there doenst need to be one as far as I can tell ... does this code look like it is going in the right direction to solve the problem of 1st thousand primes?
int prime_counter = 0;
int current_odd_number = 0;
int divisor_tester = 0;
void setup() {
size(500,500);
background(255);
}
void draw() {
while (prime_counter < 1000) {
for (i < int(sqrt(current_odd_number)); i = i + 1) {
if (current_odd_number) % i == 0) {
current_odd_number = current_odd_number + 2 }
} else if (current_odd_number) % i != 0 && i < (int(sqrt(current_odd_number))) {
i++
} else {
prime_counter = prime_counter + 1;
current_odd_number = current_odd_number + 2;
println(current_odd_number + "is prime" + prime_counter);
}
}
}
int prime_counter = 0;
int current_odd_number = 0;
int divisor_tester = 0;
void setup() {
size(500,500);
background(255);
}
void draw() {
while (prime_counter < 1000) {
for (i < int(sqrt(current_odd_number)); i = i + 1) {
if (current_odd_number) % i == 0) {
current_odd_number = current_odd_number + 2 }
} else if (current_odd_number) % i != 0 && i < (int(sqrt(current_odd_number))) {
i++
} else {
prime_counter = prime_counter + 1;
current_odd_number = current_odd_number + 2;
println(current_odd_number + "is prime" + prime_counter);
}
}
}
1