Advertisement
nguyenhappy92

S1 = 1^2 + 3^2 + 5^2 + 7^2 + … + (2n + 1)^2

Oct 22nd, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. // Tinh S1 = 1^2 + 3^2 + 5^2 + 7^2 + … + (2n + 1)^2
  2. // Khai bao thu vien neu co
  3. #include<stdio.h>
  4. #include<conio.h>
  5.  
  6. void main()
  7. {
  8. int n;
  9. scanf("%d",&n);
  10. long s=0;
  11. for(int i=0;i<=n;i++)
  12. {
  13. s=s+((2*i)+1);
  14. }
  15. printf("%ld",s);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement