Defeat other Coders | Win prizes worth 10 Lakhs

Wipro NLTH Coding Solve | Online Game | Codewindow.in

You are playing an online game. In the game, a numbers is displayed on the screen. In order to win the game, you have to Count the trailing zeros in the factorial value of the given number. Write an algorithm to count the trailing zeros in the factorial value of the given number.

Input
The input consists of an integer num, representing the number displayed on the screen.

Output
Print An integer representing the count of trailing zeros in the factorial of the given numbers.
Note: The factorial of the number is calculated as the product of integer numbers from 1 to num.

Constraints
NA

Example

Input:
5

Output:
1

Explanation:
On calculating the factorial of 5, the output is 120 (1 x2x3x4x5). There is only one trailing 0 in 120, So the output is 1.

#include <stdio.h>
int main()
{
    int num;
    scanf("%d", &num);
    long int f=1;
    int tzero=0;
    for(int i=1;i<=num;i++)
        f=f*i;
    while(f)
    {
        if(f%10==0)
        {
            tzero++;
        }
        else
            break;
        f=f/10;
    }
    printf("%d", tzero); 
}

Also Checkout

Recent Posts
Pages