Number of perfect squares between two given numbers | C # program for efficient method to count squares between a & b ; Function to count squares ; Driver Code
using System ; class GFG { static double countSquares ( int a , int b ) { return ( Math . Floor ( Math . Sqrt ( b ) ) - Math . Ceiling ( Math . Sqrt ( a ) ) + 1 ) ; } public static void Main ( ) { int a = 9 , b = 25 ; Console . Write ( " Count ▁ of ▁ squares ▁ is ▁ " + ( int ) countSquares ( a , b ) ) ; } }