smallest divisor of an integer without computing the square root explcitly
===

This code gives the smallest divisor of an integer.But the problem is i have to calculate the square root.Is there a way so that i dont have to calculate the square root explicitly???

    {
    int d,r,n;
    scanf("%d",&n);
    if(n%2==0)
    {
     printf("2 is ans"); 
    }
    else
    {
     r=sqrt(n);
      d=3;
     while((n%d!=0)&&d<r)
     {
    d=d+2; 
    }
    if(n%d==0)
     printf("ans is %d",d);
    else
      printf("ans is 1");
     }
    }