Find the smallest number of square numbers to create n
Your solution seems to be the most efficient, except for the fact that it doesn't seem to work. You could try finding all possible groups like so:

$$18=4^2+1^2+1^2$$

$$18=3^2+3^2$$

$$18=3^2+2^2+2^2+1^2$$

$$...$$

Then find the smallest group.

Your code would sure like some space. After some nice, wide spacing:

public static int solution(int number) {
    int squareCount = 0;
    while(number &gt; 0){
        int square = (int) Math.sqrt(number);
        squareCount++;
        number -= square * square;
    }       
    return squareCount; 
}


I will post a possible solution after I figure one out.