Advertisement
nguyenhappy92

Tính S(n) = 1 + 1*2 + 1*2*3 + ... + 1*2*3*...*n

Sep 16th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. // Tinh S(n) = 1 + 1*2 + 1*2*3 + ... + 1*2*3*...*n
  2. // khai bao thu vien
  3. #include<stdio.h>
  4. #include<conio.h>
  5.  
  6. void main()
  7. {
  8. // khai bao du lieu
  9. int n;
  10. // nhap du lieu
  11. scanf("%d",&n);
  12. long T=1;
  13. long S=0;
  14. for(int i=1;i<=n;i++)
  15. {
  16. T=T*i;
  17. S=S+T;
  18. }
  19. printf("%ld",S);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement