1 ~ 10 factorial java programming, factorial java programming

Source: Internet
Author: User

1 ~ 10 factorial java programming, factorial java programming

/* The following comments are obtained by writing the java content. If you have any misunderstanding, please be sure to provide guidance */

Import java. util. collections;

 

Public class jiecheng {

Public static void main (String [] args ){

New syntax = new syntax (System. in);/* The current row and the next row are in the fixed format of the java input statement */

System. out. println ("enter n (0 <n <= 10):");/* similar to C, which must be placed on the downstream */

Int n = cipher. nextInt ();/* similar to the scanf statement in C Language */

 

Int I, num = 1;/* use a cyclic statement to calculate the factorial, which is no different from the C language */

For (I = 1; I <= n; I ++ ){

Num * = I;

}

System. out. println (num);/* output statement. You can directly output the variable without using the format control operator in the C language */

}

}

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.