Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Tinh S(n) = 1^2 + 2^2 + 3^2 + ... + n^2
- //Khai bao ham thu vien
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- //khai bao bien
- int n;
- // nhap du lieu cua bien
- scanf("%d",&n);
- long s=0;
- for(int i=0;i<=n;i++)
- {
- s=s+ (i*i);
- }
- printf("%ld",s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement