求java编程:用递归求1-100偶数和?

2024-12-03 07:55:26
推荐回答(1个)
回答1:

class test
{
public static void main(String[]args)

System.out.println(Sum(2));
}
public static int Sum(int m)
{
if(m==100)
return 100;
else
return m+Sum(m+2);
}
}