View Single Post
  #3 (permalink)  
Old August 11th, 2004, 02:00 AM
mehdi62b mehdi62b is offline
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Dave thank u;
I think he has to use double because sqrt accept only double values(in my compiler using math.h)but it doesn't need using Floor...
in addition to points Dave mentioned I think if you change your testprime like below it could be better and faster..
Code:
int testprime(int c)
{
    int a;//keeps sqrt of your number
    a=sqrt((double)c);
    int counter=2;
    while(counter<=a)
    {
        if(c%counter==0) return 0;
        counter++;
    }
    return 1;//if your number is prime it returns 1 otherwise 0
}
--------------------------------------------
Mehdi.:)
Reply With Quote