- import java.util.Scanner;
- class HomeworkPra
- {
- public static void main(String[] args)
- {
- System.out.println("请输入数字:");
- Scanner lo = new Scanner(System.in);
- int lon = lo.nextInt();
- long fact=1;
- for (int x=1;x<=lon ;x++ )
- {
- fact *= x;
- }
- System.out.println(fact);
- }
- }
复制代码 从键盘录入一个数字,并求其阶乘 |