Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ofstream fout("bac.txt");
- int getCntOfBaseInNFact(int n, int base) {
- int cnt = 0, powOfBase = base;
- while (n / powOfBase) {
- cnt += n / powOfBase;
- powOfBase *= base;
- }
- return cnt;
- }
- int main() {
- int n;
- cin >> n;
- int fr5 = getCntOfBaseInNFact(n, 5);
- int fr9 = getCntOfBaseInNFact(n, 3) / 2;
- fout << (fr9 > fr5 ? fr5 : fr9) << '\n';
- fout.close();
- return 0;
- }
Add Comment
Please, Sign In to add comment