递归小练习
package IO.file.test; public class diguiDemo { public static void main(String[] args) { show(6);//十进制转二进制 System.out.println(sum(4));//1+2+3+4+....值 } public static void show(int num) { if(num>0){ System.out.println(num%2); show(num/2); } } public static int sum(int num) { if(num==1) return 1; return num+sum(num-1); } }