package com.cn.peitest.diGui; public class DiGui { //打印99乘法表 public static void main(String[] args) { for(int i=1; i<=9;i++){ for(int j=1; j<=i; j++){ System.out.print(j+" * "+i+ " = "+(i*j) +" "); } System.out.println(); } //m(10); } //递归 public static void m(int i) { if (i == 1) { System.out.println("1*1=1 "); } else { m(i - 1); for (int j = 1; j <= i; j++) { System.out.print(j + "*" + i + "=" + j * i + " "); } System.out.println(); } } }
//求和 public class DiGui { public static void main(String[] args) { int m= sum(6); System.out.println(m); } public static int sum(int m) { if(m==1) { return 1; } return m+sum(m-1); } }