×

# Small integer factorial

 0 #include  using namespace std; int fact(int x) { int f=1; for(int i=1;i<=x;i++) { f=f*i; } return f; } int main() { int t,n,i,facto; cin>>t; for(i=0;i>n; facto=fact(n); cout<

Here you had unwanted equal signs and one more thing use long instead of int because the number can be large but I don't think so that even long long can hold the factorial of 100, you might need different approach

# include<iostream>

using namespace std;

int fact(int x)

{

int f=1;


for(int i=1;i<=x;i++)

{

f=f*i;


}

return f;

}

int main()

{ int t,n,i,facto;

cin>>t;

for(i=0;i<t;i++) {="" cin="">>n;

facto=fact(n);

cout<<facto<<"\n";

}

return 0;

}

2★kunnu120
5189
accept rate: 5%

 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×151
×5
×4

question asked: 16 Sep '17, 07:29

question was seen: 175 times

last updated: 16 Sep '17, 07:53