public class DiGui
{
public static void main(String[] args)
{
System.out.println("Sum="+getSum(5));
}
public static long getProdect(int n)
{
if(n==1)
return 1;
return n*getProdect(n-1);
}
public static long getSum(int n)
{
if(n==1)
return getProdect(n);
return getProdect(n)+getSum(n-1);
}
} |