fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. unsigned long long isFact(unsigned long long N)
  7. {
  8. unsigned long long f = 1;
  9. for(unsigned long long i = 1; f < N; ++i)
  10. {
  11. if ((f *= i) == N) return i;
  12. }
  13. return 0;
  14. }
  15.  
  16. int main(int argc, const char * argv[])
  17. {
  18. cout << isFact(5039) << endl;
  19. cout << isFact(5040) << endl;
  20. cout << isFact(5041) << endl;
  21. }
  22.  
Success #stdin #stdout 0s 4372KB
stdin
Standard input is empty
stdout
0
7
0