int is_prime(int i, int N, int j);
void setup() {
Serial.begin(115200);
Serial.print("Prime Number Calculator");
Serial.print("\n");
}
void loop() {
int N,i,j;
Serial.print("Input N (>1): ");
while(Serial.available ()==0);
N=Serial.parseInt ();
N= is_prime(i,j,N);
Serial.print(i);Serial.print("\t");
}
int is_prime(int i, int N, int j){
for(i=1; i<=N; i++){
boolean flag=true;
for(j=2; j<=(i-1); j++){
if(i%j==0){
flag=false;
break;
}
}
if(flag==true){
return(i);
}
}
}
The project has me ask the user for a number, from that i have to use a prototype function to see if its prime and print.
I cant figure out a away to call the function or if i need to change to prototype. Any suggestions?