spoj BCFACT v1.01


SUBMITTED BY: Guest

DATE: Feb. 16, 2014, 9:04 a.m.

FORMAT: C++

SIZE: 507 Bytes

HITS: 1257

  1. //Haha TTpro
  2. //BCFACT
  3. //http://www.spoj.com/PTIT/problems/BCFACT/
  4. #include <iostream>
  5. using namespace std;
  6. long long int giaithua(int a);
  7. int main()
  8. {
  9. int a;
  10. long long int s;
  11. while (true)
  12. {
  13. cin >>a;
  14. if (a==0) break;
  15. s= giaithua(a);
  16. cout<<s<<endl;
  17. }
  18. }
  19. long long int giaithua(int a)
  20. {
  21. long long int s=1;
  22. int i;
  23. for (i=1;i<=a;i++)
  24. {
  25. s=s*i;
  26. }
  27. return s;
  28. }

comments powered by Disqus