#include<stdio.h> int main() { int i,N; unsigned long sum; /*read value of N*/ printf(“\nEnter the value of N :: “); scanf(“%d”,&N); /*set sum by 0*/ sum=0; /*calculate sum of the series*/ for(i=1;i<=N;i++) sum= sum+ (i*i); /*print the sum*/ printf(“\nSum of the series is :: [ %ld ]\n”,sum); return 0; } Nhớ vote 5 sao Bình luận
S=1^2+2^2+3^2+….+ n^^2 S=1+ 2.(1+1) + 3.(2+1) +…..+ n(n-1 +1) S=1 + 1.2 +2 + 2.3 + 3 +…….+ (n-1).n + n S= (1 + 2 +3 +….+n) + (1.2 + 2.3 + 3.4 + ……+ (n-1)n ) S= n(n+1)2n(n+1)2 + n(n+1)(n−1)3n(n+1)(n−1)3 S= 3n(n+1)+2n(n+1)(n−1)63n(n+1)+2n(n+1)(n−1)6 S= n(n+1)(2n+1)6 Bình luận
#include<stdio.h>
int main()
{
int i,N;
unsigned long sum;
/*read value of N*/
printf(“\nEnter the value of N :: “);
scanf(“%d”,&N);
/*set sum by 0*/
sum=0; /*calculate sum of the series*/
for(i=1;i<=N;i++)
sum= sum+ (i*i);
/*print the sum*/ printf(“\nSum of the series is :: [ %ld ]\n”,sum);
return 0;
}
Nhớ vote 5 sao
S=1^2+2^2+3^2+….+ n^^2
S=1+ 2.(1+1) + 3.(2+1) +…..+ n(n-1 +1)
S=1 + 1.2 +2 + 2.3 + 3 +…….+ (n-1).n + n
S= (1 + 2 +3 +….+n) + (1.2 + 2.3 + 3.4 + ……+ (n-1)n )
S= n(n+1)2n(n+1)2 + n(n+1)(n−1)3n(n+1)(n−1)3
S= 3n(n+1)+2n(n+1)(n−1)63n(n+1)+2n(n+1)(n−1)6
S= n(n+1)(2n+1)6