Consider the following program segment. Without using Dr.Java, What this program prints? (my class uses Dr.Java)

The answer that this program prints which i got was: 22
Is my answer correct?

public class sample {
public static void main(String[] args){
Sample x = new Sample();
int i = 10;
int b = x.g(i);
System.out.println(b + i);
}
public int f(int d){
int n = 0;
while(n*n < d){
n++;
}
return n-1;
}
public int g(int a){
int b = 0;
int c;
for(int n = 0; n < a; n++){
c = f(n);
b = b + c;
}
return b;
}
}

4 answers

I assume your answer is correct, if you ran the code and that's what it printed.
i didn't run the program (i swear). i only looked the the program and i was think if the answer was 22
so, run it, and see whether you were right!
ok thanks