I don't understand the following recursive code.
int func(int num){
if(num == 1){
return 1;
}
else{
return (func(num-1) + num));
}
}
public static void main(String[] args) {
System.out.println(func(100));
}
So the output is 5050. I don't understand why that is. Can someone explain to me the working of the code?