Advertisement
tuki2501

factorialcalculator.cpp

Nov 18th, 2021
1,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long double ld;
  5.  
  6. const ld EPS = 1e-9;
  7.  
  8. int main() {
  9.   int n; cin >> n;
  10.   ld coef = 1; int expo = 0;
  11.   for (ld i = 1; i <= n; i++) {
  12.     coef *= i;
  13.     while (!(coef < 10.0 - EPS)) {
  14.       coef /= 10.0;
  15.       expo++;
  16.     }
  17.   }
  18.   cout << fixed << setprecision(9) << coef << "e+" << expo << '\n';
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement