mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 05:21:49 +03:00
Create factorial_trailing_zeroes.c
This commit is contained in:
parent
41dede7144
commit
7ed9d6dbee
25
misc/factorial_trailing_zeroes.c
Normal file
25
misc/factorial_trailing_zeroes.c
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
programme for computing number of zeroes at the end of factorial of a given number n
|
||||
*/
|
||||
#include<stdio.h>
|
||||
#include<math.h> //including math.h header file to use pow function
|
||||
int main()
|
||||
{
|
||||
int i,n,test=0,count=0;
|
||||
//taking input number n
|
||||
scanf("%d",&n);
|
||||
|
||||
//looping from 1 till loop break
|
||||
for(i=1;;i++)
|
||||
{
|
||||
test=n/pow(5,i);//division of n by ith power of 5(storing in integer form)
|
||||
if(test!=0) //condition for zeroes at end corresponding individual ith case
|
||||
{
|
||||
count=count+test;
|
||||
}
|
||||
else
|
||||
break; //break the loop for if test=0
|
||||
}
|
||||
printf("%d\n",count);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user