Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: invalid operands to binary % (have 'double' and 'double')

Tags:

I have a program I am writing that lists 100,000 prime numbers. It works fine for 10 numbers, but after so many numbers they turn into negative values. I changed the ints to long ints and that did not change anything, then I changed them to doubles and I get the error listed in the title. What should my variable be? Keep in mind I am still new to programing. I also looked at some previous posts and did not see the answer.

 int is_prime(double x,char array[]){
 //doesnt use array but I put it in there

     double j=2;//divider
     for(j=2;j<=pow(x,0.5);j++){
         if((x%j==0)){
             return(0);
         }   //isnt prime  
     }
     return(1);// because it is prime.
 }