N!的位数 【java 高精度处理】
2017-07-12 19:11
141 查看
Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!
Input
One N in one line, process to the end of file.
Output
For each N, output N! in one line.
Sample Input
1
2
3
Sample Output
1
2
6
Input
One N in one line, process to the end of file.
Output
For each N, output N! in one line.
Sample Input
1
2
3
Sample Output
1
2
6
import java.util.*; import java.math.*; class Main { public static void main(String[] args){ Scanner cin = new Scanner (System.in); while(cin.hasNext()){ int n; n=cin.nextInt(); BigInteger sum=BigInteger.ONE; for(int i = 1 ; i <= n ;i++ ){ BigInteger a=BigInteger.valueOf(i); sum=sum.multiply(a); } System.out.println(sum); } } }
相关文章推荐
- java 处理高精度计算
- java 位数补0处理
- java处理高精度的商业计算
- java 处理高精度问题
- JAVA高精度数值运算方法,小数点后保留位数,结合相关例题进行介绍!
- java 处理高精度计算
- Exponentiation 【java 处理高精度】
- java中小数的处理:高精度运算用bigDecimal类,精度保留方法,即舍入方式的指定
- Java处理高精度问题模板
- 大菲波数 【java 高精度处理】
- java 位数补0处理
- java中大数处理和高精度小数处理(so easy)
- 大数高精度之java处理
- Java 使用BigDecimal类处理高精度计算
- java 处理高精度计算问题
- java 位数补0处理
- java 大数用法 处理高精度
- java中小数的处理:高精度运算用bigDecimal类,精度保留方法,即舍入方式的指定
- java 处理高精度计算
- How Many Fibs? 【java 处理高精度】