Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

factorial problem in c - "wrong answer"

$
0
0

i checked every input. Its giving the right output but the judge says "wrong answer". Whats wrong with it?

include <stdio.h>

include <stdlib.h>

include<math.h>

int power(int);

int main()
{ int t,n,q;

scanf("%d",&t);

while(t--)
{
scanf("%d",&n); int powerv=power(n);

     int powsum=0;
    for(q=1;q<powerv;++q)
    {
        float f=n/pow(5,q);

       powsum=powsum + floor(f);

    }
    printf("%d\n",powsum);

}
return 0;

}

int power(int n)

{

int i;
for(i=0;i<n;i++)
{
    if(pow(5,i)>n)
        break;
}
return i;

}


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>