I think you need the number of integer between the first integer after sqrt(first) and before sqrt(last).
To get the first integer after, you can use
Math.Ceiling
.
To get the first integer before, you can use
Math.Floor
.
Then the complete formula should be :
Math.Floor(Math.Sqrt(last)) - Math.Ceiling(Math.Sqrt(first)) + 1
+1 because if the first integer before last is the first integer after first, the difference will be 0 but you have 1 integer.
For example : with sqrt(first) = 2.3 and sqrt(last) = 3.2
you have 1 integer between the two numbers = 3 but Floor(3.2)=3 and Ceiling(2.3)=3
and Floor(3.2)-Ceiling(2.3) = 0.
This code is written using C#, but I'm sure you can found the
floor
and
ceiling
functions in other language.