Welcome! This is the first post of the Find and Resolve the Bug Series.
As described in the comment, the sum function is supposed to sum up the numbers from 1 to n
The code;
// define a function to sum up the numbers from 1 to n
int sum(int n) {
int sum = 0;
for (int i = 1; i < n; i++) {
sum += i;
}
return sum;
}
What could fix the issue in the code above?
Comments
Post a Comment