56
1+0+3 is the digit sum of 103
-3
if (n%2==0) sum=n/2*(n+1); else sum=(n+1)/2*n;
Two factors of what? To sum to -2, some possibilities are: -1, -1 => what is 1 0, -2 => what is 0 1, -3 => what is -3 2, -4 => what is -8 3, -5 => what is -15 4, -6 => what is -24
You add the numbers in a loop. Here is an example in Java:int sum = 0;for (int i = 1; i
-1+1+2+3+5= 10 First, you move 1 left of "0", which is -1. Then, you move 1 digit to the right, which puts you back at "0". Add 2, add 3, and add 5. The sum is 10.
The sum is 1511.
-1, 0, 1
3
Did you mean 1-2+3-4+5-6....till n ?? If yes, then here it is: #include<iostream.h> void main() { int n,sum=0,check=1; cout<<"Enter n "; cin>>n; for(int i=1;i<=n;i++) { sum+=(check*i); check*=-1; } cout<<"The result of series is: "<<sum; }
0
87