Professional Documents
Culture Documents
S=2+4+..+(2n)= n*(n+1)
S=1*2-2*3+3*4-...±n*(n+1)= S=k*(k+1)*-2 .
n=2k=> k=n/2
1. ( a + b) % c = ( ( a % c ) + ( b % c ) ) % c
2. ( a * b) % c = ( ( a % c ) * ( b % c ) ) % c
3. ( a – b) % c = ( ( a % c ) – ( b % c ) ) % c
Note: In most of the programming languages (like in C/C++) when you perform modular
operation with negative numbers it gives negative result like -5%3 = -2, but what the
result comes after modular operation should be in the range 0 to n-1 means the -5%3 =
1. So for this convert it into positive modular equivalent.