for循环计算阶乘

1 int x = 10;
2         for(int y = x - 1; y >= 1; y--)
3         {
4             x = x * y;
5         }
6         System.out.println(x);

从10乘到1的阶乘写法。

1         long js = 1;
2         
3                  for(int i = 1; i <= 10; i++)
4         
5                 {
6             js = js * i;
7         }
8                 
9                 System.out.println(js);

从1乘到10的写法

 
原文地址:https://www.cnblogs.com/wgbs25673578/p/4853022.html