sppoj factorial earlier soln

//factorial of large numbers #include<iostream> using namespace std; int main() { int tc,n; int a[200]; cin>>tc; while(tc--) { cin>>n; a[0]=1; int m=1; int carry=0; for(int i=1;i<=n;i++) { for(int j=0;j<m;j++) { int x=a[j]*i+carry; a[j]=x%10; carry=x/10; } while(carry>0) { a[m]=carry%10; carry/=10; m++; } } for(int p=m-1;p>=0;p--) cout<<a[p]; cout<<endl; } return 0; }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.