You are not logged in. Please login at www.codechef.com to post your questions!

×

factorial in c

my code is running well in code block but it shows wrong in codechef editor why?? here is my code....

include<stdio.h>

                                int main()
                                {int b,n=0,i;
                                long int T,N;
                                scanf("%ld",&T);
                                for(i=1;i<=T;i++)
                                {scanf("%ld",&N);
                                n=N;
                                b=0;
                                while(n>4){
                                b=b+n/5;
                                n=n/5;}
                                printf("%d",b);}
                                return 0;}
This question is marked "community wiki".

asked 23 Jul '17, 16:25

shahrav's gravatar image

0★shahrav
1
accept rate: 0%


New line character mate. You need to put each answer or printf in a new line.

Put a new line character in your printf().

link

answered 23 Jul '17, 16:41

utkalsinha's gravatar image

5★utkalsinha
723118
accept rate: 12%

Your logic is correct but you forgot \n (new line char) while printing output, so it's returning WA. just replace

printf("%d",b)

with

printf("%d\n",b)

then it should work fine.. :)

link

answered 23 Jul '17, 16:42

kauts_kanu's gravatar image

5★kauts_kanu
1.0k19
accept rate: 19%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×300

question asked: 23 Jul '17, 16:25

question was seen: 131 times

last updated: 23 Jul '17, 16:42