import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.math.BigInteger;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author corywu
*/
public class Factorial {
public static double factorial(int num) {
if (num == 1) {
return 1;
} else {
return num * factorial(num - 1);
}
}
public static void main(String args[]) {
FileOutputStream fos = null;
try {
System.out.println(factorial(10));
BigInteger x = BigInteger.valueOf(1);
for (int i = 2; i <= 100000; i++) {
x = x.multiply(BigInteger.valueOf(i));
}
fos = new FileOutputStream("c:\\abc.txt");
OutputStreamWriter opsw = new OutputStreamWriter(fos);
try {
opsw.write(x.toString());
opsw.flush();
} catch (IOException ex) {
ex.printStackTrace();
}
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} finally {
try {
fos.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
100000的阶乘
最新推荐文章于 2021-05-22 23:27:55 发布