Sort by

recency

|

1593 Discussions

|

  • + 0 comments

    a1=math.ceil(math.sqrt(a)) b1=math.floor(math.sqrt(b)) roots=(x for x in range(a1,b1+1)) roots1=list(roots) return len(roots1)

  • + 0 comments
    Here is my Java Code ===============
    public static int squares(int a, int b) {
        boolean status = Math.sqrt(a)% 1 ==0;
        int startRoot = (int) Math.sqrt(a);
        int endRoot = (int) Math.sqrt(b);if (status){
        return endRoot-startRoot+1;
    }else{
        return endRoot-startRoot;
    }
    
    
    }
    
  • + 0 comments

    Python3 solution:

    def squares(a, b):
        # Write your code here
        count = 0
        x = math.sqrt(a)
        if x == int(x):
            rangex = x
        else:
            rangex = int(math.ceil(x))
            
        y = math.sqrt(b)
        if y == int(y):
            rangey = y
        else:
            rangey = int(math.floor(y))
            
        if rangey < rangex:
            return count
            
        for i in range(int(rangex),int(rangey+1)):
            count += 1
        
        return count
    
  • + 0 comments

    for _ in range(int(input())): import math a,b=map(int,input().split()) print(math.floor(b0.5) - math.ceil(a0.5) + 1)

    This is solution for begginer

  • + 0 comments
    def squares(a, b):
        # Write your code here
        count = 0
        start = int( math.sqrt(a))
        end = int(math.sqrt(b))
        
        for i in range(start,end+1):
            if i**2 >=a and i**2<=b:
                count+=1
                
        return count