A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a C++ program to find the number of trailing zeroes in a given factorial
Q:

Write a C++ program to find the number of trailing zeroes in a given factorial

0

Write a C++ program to find the number of trailing zeroes in a given factorial

Input: n = 4
Output: 0
Input: n = 6
Output: 1

Sample Output:

Number of trailing zeroes of factorial 4 = 0

Number of trailing zeroes of factorial 6 = 1

Number of trailing zeroes of factorial 7 = 1

Number of trailing zeroes of factorial 10 = 2

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <iostream>
using namespace std;

int trailing_Zeroes(int n) {
        int number = 0;
        while (n > 0) {
            number += n / 5;
            n /= 5;
        }
        return number;
    }

int main(void)
{
    int n = 4;
    cout << "\nNumber of trailing zeroes of factorial " << n << " = " << trailing_Zeroes(n) << endl; 
    n = 6;
    cout << "\nNumber of trailing zeroes of factorial " << n << " = " << trailing_Zeroes(n) << endl;     
    n = 7;
    cout << "\nNumber of trailing zeroes of factorial " << n << " = " << trailing_Zeroes(n) << endl;  
    n = 10;
    cout << "\nNumber of trailing zeroes of factorial " << n << " = " << trailing_Zeroes(n) << endl; 
    return 0;   
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now