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

Small Factorial

$
0
0

//my code for smallfactorial,it's giving correct output in my system but not here..please tell me whats wrong in it???

#include <stdio.h>
#include <stdlib.h>
int fact(int);

int main()
{
    int t,n,r;
    scanf("%d",&t);
    while(t--)
    {
        r=0;
        scanf("%d",&n);
        r=fact(n);
        printf("%d\n",r);
    }
    return 0;
}
int fact(int n)
{

     if(n==1)
        return 1;
    else
        return(n*fact(n-1));
}

Viewing all articles
Browse latest Browse all 40121

Trending Articles



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