Factorial of 1076.N

Source: Internet
Author: User

Title Description:

Enter a positive integer n to output the factorial of N.

Input:

Positive integer N (0<=n<=1000)

Output:

Input may include multiple sets of data, for each set of input data, the factorial of the output n

Sample input:
4515
Sample output:
241201307674368000


#include <string.h>#include<stdio.h>using namespacestd;structbiginteger{intdigit[ +]; intsize; voidInit () {//Initialize         for(intI=0;i< +; i++) digit[i]=0; Size=0; }    void Set(intx) {//set an X to a high-precision integerinit ();  Do{digit[size++]=x%10000; X/=10000; } while(x!=0); }    voidOutput () {//4-bit, 4-bit output         for(inti=size-1; i>=0; i--){            if(i!=size-1) printf ("%04d", Digit[i]); Elseprintf"%d", Digit[i]); } printf ("\ n"); } BigIntegeroperator* (intXConst{BigInteger ret;       Ret.init (); intcarry=0;  for(intI=0; i<size;i++){           inttemp=x*digit[i]+carry; Carry=temp/10000; Temp%=10000; Ret.digit[ret.size++]=temp; }       if(carry!=0) {ret.digit[ret.size++]=carry; }       returnret; }}a;intMain () {intN;  while(SCANF ("%d", &n)! =EOF)        {A.init (); A.Set(1);  for(intI=1; i<=n;i++) {a=a*i;    } a.output (); }    return 0;}

Factorial of 1076.N

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.