Squre root of a given number without sqrt function
by ujjal roy
long long int floorSqrt(long long int x)
{
// Your code goes here
long long int r,i,ans;
if(x==0||x==1)return x;
else
{
ans=1,i=1;
for(i=1;ans<=x;i++)
{
ans=i*i;
}
}
return (i-2);
}
Squre root of a given number without sqrt function
by ujjal roy
long long int floorSqrt(long long int x)
{
// Your code goes here
long long int r,i,ans;
if(x==0||x==1)return x;
else
{
ans=1,i=1;
for(i=1;ans<=x;i++)
{
ans=i*i;
}
}
return (i-2);
}
0 Comments