Finding the sum of many square root values (greatest integer function)?

658 Views Asked by At

Problem

I am not really sure how to go about this mathematically, but I used my programming skills to find the answer quite quickly:

public static void main(String[]args) 
{ 
int x; 
int p = 0; 

for(x = 0; x <= 36; x++) 
{ 
p+=Math.sqrt(x);    
} 
System.out.println(p); 
} 

What this does is adds each square root value to the past value all the way to sqr(36). The sum ends up being 131 or B. I can't really get anywhere outside of this, so any help is appreciated.

1

There are 1 best solutions below

5
On BEST ANSWER

Hint: You need to pay attention to the values $N$ such that $\sqrt{N}$ is an integer, namely $1,4,9,16,25$ and $36$. Now, for instance, if $4 \leq N < 9$, then $2 \leq \sqrt{N} < 3$, so that $\lfloor{\sqrt{N}}\rfloor = 2$. So, for instance, $\lfloor{\sqrt{4}}\rfloor + \lfloor{\sqrt{5}}\rfloor + \lfloor{\sqrt{6}}\rfloor + \lfloor{\sqrt{7}}\rfloor + \lfloor{\sqrt{8}}\rfloor = 2 + 2 + 2 + 2 + 2 = 5 \cdot 2 = 10$.

Can you finish it from here?