Find_Nearest(i , prev , n)
{
int sqr=n*n;
if(sqr > i)
{
if((sqr-i)>(i-prev))
return sqr ;
else
return prev;
}
Find_Nearest(i,sqr,n+1);
}
initial call value : Find_Nearest(27, 0, 1);
prev= previous square value.
Thanks
Venkat
http://cloud-computation.blogspot.com/
On Aug 7, 7:41 pm, Nikhil Veliath <[email protected]> wrote:
> write a recursive code to print the nearest square of a number....
>
> eg if no is 27
>
> the nearest square is 5....
>
> it should also take care of large nos...
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.