public class Two_n {
public static void main(String[] args) {
System.out.println(power2(8));
}
public static int power2(Integer n) {
if(n<0) {
return 0;
}
if(n==0) {
return 1;
}else {
return 2*power2(n-1);
}
}
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交