返回列表 發帖
  1. public class Ch15 {
  2.         static int f1 (int a)
  3.         {
  4.                 if(a==1)
  5.                         return 1;
  6.                 else
  7.                         return a+f1(a-1);
  8.         }

  9.         public static void main(String[] args) {
  10.                  System.out.println("1+2+3+.....+100="+f1(100));
  11.                  System.out.println("1+2+3+.....+599="+f1(599));
  12.         }

  13. }
複製代碼

TOP

返回列表