We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
that's wrong... case A=B only returns 0 when A is not a square integer. When A is a square integer and A=B, then you return 1. The following code (as others have suggested) does indeed satisfy the "A=B case" if you understand Floor and Ceiling functions:
int count =
(int)Math.Floor(Math.Sqrt(b)) - (int)Math.Ceiling(Math.Sqrt(a)) + 1;
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sherlock and Squares
You are viewing a single comment's thread. Return to all comments →
that's wrong... case A=B only returns 0 when A is not a square integer. When A is a square integer and A=B, then you return 1. The following code (as others have suggested) does indeed satisfy the "A=B case" if you understand Floor and Ceiling functions: