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

×

Small Factorial (What's wrong with this code?)

include <iostream>

using namespace std; int factorial(int); int main() { int t; cin>>t; int a[t],fact; for(int i=0;i<t;i++) {="" cin="">>a[i]; } for(int i=0;i<t;i++) { fact=factorial(a[i]); cout<<fact<<"\n"; } return 0; }

int factorial(int num) { if(num<=1) return 1; else return num*factorial(num-1); }

asked 11 Oct, 18:15

anieshgupta's gravatar image

0★anieshgupta
1
accept rate: 0%

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:

×184

question asked: 11 Oct, 18:15

question was seen: 20 times

last updated: 11 Oct, 18:15