You are viewing a single comment's thread. Return to all comments →
Basically, you calculate the lowest square integer and the largest square integer. The number of integers in that range is the result.
C#:
public static int squares(int a, int b) { int firstSqrt = (int)(Math.Ceiling(Math.Sqrt(a)) / 1); int lastSqrt = (int)(Math.Floor(Math.Sqrt(b)) / 1); return lastSqrt - firstSqrt + 1; }
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 →
Basically, you calculate the lowest square integer and the largest square integer. The number of integers in that range is the result.
C#: