Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and
including n. So sum_to(10) would be 1+2+3. . . +10 which would return the value 55.
into sum=0;
int sum_to(n){
for(int i=1;i=<n;i++){
sum=sum+i;
}
return sum;
}
Comments
Leave a comment