Answer:
int sumNumber(int n){
if(n < 0)
return 0;
int sum = 0;
int i;
for(i = 0; i <= n; i++){
sum = sum + i;
}
return sum;
}
Explanation:
I am going to write a C code for this.
A for loop and an initialized variable is sufficient to solve this problem.
int sumNumber(int n){
if(n < 0)
return 0;
int sum = 0;
int i;
for(i = 0; i <= n; i++){
sum = sum + i;
}
return sum;
}