1斐波那契;
public int foo(int n){
return n==1||n==2?:foo(n-1)+foo(n-2);
}
2.把十进制转二进制字符串
public String foo(int n){
return n/2<0?n%2:foo(n/2)+n%2;
}
3.求一个数的喝,如123456 1+2+3+4+5+6 =21, 2+1 = 3
直到和为一位数时
public int foo(int n ){
if(n/10<0)
{
return n;
}
else{
int sum =
return
}
}
private int foo1(int n){
return n/10<0?n:foo1(n/10)+n%
}