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


Why my solution to problem is flagged wrong?

#include <stdio.h>

long factorial(int num);

int main()
    int t;
    scanf("%d", &t);

        int num;
        scanf("%d", &num);

        printf("%d\n", factorial(num));

    return 0;

long factorial(int num)
    if(num == 0) return 1;
    else return (num * factorial(num - 1));

So this is my solution to small factorial problem, when I tested it locally it gives the desired output but when I submit this it flags it as wrong one. Can someone let me know why it is wrong?

asked 17 Oct '18, 23:46

pavanjadhaw's gravatar image

accept rate: 0%

Try something like factorial(100). You need a function to handle such big numbers. Another practice for you :)


answered 18 Oct '18, 00:54

tieros's gravatar image

accept rate: 12%

edited 18 Oct '18, 00:54

toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 17 Oct '18, 23:46

question was seen: 98 times

last updated: 18 Oct '18, 00:54