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

×

small factorial (Why wrong?)

include<stdio.h>

long long int fact(int n); int main() { int n,i,k[i]; long int d[i]; scanf("%d",&n); for(i=0;i<n;i++) {="" if(1<="n&lt;=100" &&="" 1<="k&lt;=100)" scanf("%d",&k[i]);="" }="" for(i="0;i&lt;n;i++)" {="" d[i]="fact(k[i]);" printf("%lld\\n",d[i]);="" }="" return="" 0;="" }="" long="" long="" int="" fact(int="" n)="" {="" if(n="">=1) return(n*fact(n-1)); else return 1; }

asked 02 Sep '17, 17:34

niksrocks123's gravatar image

2★niksrocks123
11
accept rate: 0%

edited 02 Sep '17, 17:35


https://www.codechef.com/viewsolution/13353189

Check this. I hope you understand.

link

answered 02 Sep '17, 17:46

mukul_vashisht's gravatar image

4★mukul_vashisht
16
accept rate: 10%

If you want to solve it using recursion. Have a look at: https://www.codechef.com/viewsolution/15220161

link

answered 02 Sep '17, 17:49

mukul_vashisht's gravatar image

4★mukul_vashisht
16
accept rate: 10%

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:

×196
×33

question asked: 02 Sep '17, 17:34

question was seen: 183 times

last updated: 02 Sep '17, 17:49