阶乘运算,随便写一个1000!,结论大家自己去总结吧!
================Python版================
print reduce(lambda x,y:x*y, range(1, 1001))
================Java版================
import java.io.*;
import java.math.*;
public class Main
{
public static BigDecimal fact(int num)
{
BigDecimal sum = new BigDecimal(1.0);
int i;
BigDecimal a;
for(i = 1; i <= num; i++)
{
a = new BigDecimal(i);
sum =sum.multiply(a);
}
return sum;
}
public static void main(String args[])
{
System.out.println(fact(1000));
}
}
================Python版================
print reduce(lambda x,y:x*y, range(1, 1001))
================Java版================
import java.io.*;
import java.math.*;
public class Main
{
public static BigDecimal fact(int num)
{
BigDecimal sum = new BigDecimal(1.0);
int i;
BigDecimal a;
for(i = 1; i <= num; i++)
{
a = new BigDecimal(i);
sum =sum.multiply(a);
}
return sum;
}
public static void main(String args[])
{
System.out.println(fact(1000));
}
}