Nine degrees OJ topic 1076:n's factorial (Java) uses the BigInteger example.

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
1  PackageA;2 ImportJava.math.BigInteger;3 ImportJava.util.*;4  Public classmain{5      Public Static  voidMain (string[] args) {6Scanner cin =NewScanner (system.in); 7          while(Cin.hasnext ()) {8 BigInteger B1;9BigInteger b2=Biginteger.one;TenBigInteger b3=Biginteger.one; Oneb1=Cin.nextbiginteger (); A              while(B1.compareto (Biginteger.zero) >0) -             { -B2=b2.multiply (B1); theb1=B1.subtract (B3);  -             }             - System.out.println (b2.tostring ()); -      } + Cin.close ();  -     }   +}

Nine degrees OJ topic 1076:n's factorial (Java) uses the BigInteger example.

Related Article

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.