You are given a number N. How many zeroes does N! end-on?
Example:
Input: n = 20
Output: 4
Approach
C++
#include <bits/stdc++.h>using namespace std;long long zrZr(long long n){long long res = 0;for (long long i = 5; n / i > 0; i *= 5){res += n / i;}return res;}int main(){long long n = 20;cout << zrZr(n) << "\n";return 0;}
No comments:
Post a Comment