17 Mar 2016

Trailing Zeroes


/*

Given a number find the number of trailing zeroes in its factorial.
Input Format
A single integer - N
Output Format
Print a single integer which is the number of trailing zeroes.
Input Constraints
1 <= N <= 1000

*/

#include <stdio.h>

int main(){
   
    int i,N,z,k;
    scanf("%d",&N);
   
    z=0;
    k=1;
    i=1;
    while(1){
       
        k=(int)(N/pow(5,i));
        if(k<1) break;
        z+=k;
        i++;
    }
   
    printf("%d",z);
    return 0;
}

Categories: , , ,

Related Posts:

  • perfect_number /*  program to check whether a given no. is a ""perfect no."" or not. a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors e… Read More
  • Prime_Composite /* program to check entered number is prime or composite....   */ #include<iostream.h> #include<conio.h> void main() { int n,i=2,a=0; clrscr(); cout<<"Enter th number=… Read More
  • pattern_nested loops /* program in c to print following pattern... &  &  &  &  &  &  &    &  &  &  &  &       … Read More
  • pattern_rectangle /* program to print following pattern *********************** *                     * *                     * *&… Read More
  • Inverse_matrix /*   program to find inverse of a matrix...   */ #include<stdio.h> int main() {   int a[3][3],i,j;   float determinant=0;   printf("Enter the 9 elements of matrix: "… Read More

0 comments:

Post a Comment

Copyright © 2025 UPgradeCODING | Powered by Blogger