Advertisement
nguyenhappy92

Tính n!, với n là một số nguyên dương.

Oct 16th, 2015
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. // Tinh giai thua cua mot so n
  2. // Khai bao cac ham thu vien neu cos
  3. #include<stdio.h>
  4. #include<conio.h>
  5.  
  6. void main()
  7. {
  8. int n;
  9. scanf(" %d", &n);
  10. long double s=1;
  11. if(n==0||n==1)
  12. {
  13. printf("1");
  14. }
  15. else
  16. {
  17. for(int i=2;i<=n;i++)
  18. {
  19. s=s*i;
  20. }
  21. printf(" %.0lf",s);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement