The sum of the first n cubed numbers is: [n*(n+1)/2]2 which is the same as the square of the sum of the first n numbers.
The average of n numbers = (sum of n numbers) / (count of n numbers).
main() { int i, n, sum=0; cout<<"Enter the limit"; cin>>n; for(i=0;i<=n;i++) sum=sum+i; cout<<"sum of "<<n<<" natural numbers ="<<sum; getch(); }
Mean = (sum of the n numbers)/n
The sum of the first "n" numbers is equal to n(n+1)/2.
i need 2 numbers whose sum is 832AnswerThe numbers are n and (832 - n) where n is any number from 0 to 416.
There is no formula that will sum n even numbers without further qualifications: for example, n even numbers in a sequence.
int sum = 0; int i; for(i = 0; i < n; ++i) { sum += i; }
sum = 0 for(n = 0; n <= 10; n += 2) sum += n;
#include<stdio.h> void main() { long long int sum=0,n,i,b; printf("How many numbers do you want to add?\n"); scanf("%lld",&n); printf("Enter those %lld numbers\n",n); for(i=0;i<n;i++) { scanf("%lld",&b); sum=sum+b; } printf("Sum of all the numbers you entered is %lld",sum); getch(); }
int sum(n) { if (n==0) return 0; else return n+sum(n-1); }
Sum of first n natural numbers is (n) x (n + 1)/2 Here we have the sum = 100 x (101)/2 = 50 x 101 = 5050