class DiGui
{
public static void main(String[] args)
{
System.out.println(fun(10));
}
public static int fun(int n){
int sum = 0;
if(n%2 == 1){
n--;
if (n ==0)
{
sum += 0;
}else{
sum = n + fun(n-2);
}
return sum;
}else{
if (n ==0)
{
sum += 0;
}else{
sum = n + fun(n-2);
}
return sum;
}
}
}
|
|