張佑維Java遞迴函數Recursion=Recursive Function=Recursive Methods
w3school學習Java public class Main { /*張佑維rescursion遞迴函數*/ public static void main(String[] args) { int x = 11 ; /*Java程式必須以main起始*/ for (int i = 0 ; i 0) { return k + sum(k - 1); } else { return 0;}} /*函數sum呼叫自己,稱遞迴*/ public static int f(int k) { if (k > 0) { return k * f(k - 1); } else { return 1;}} /* 0!=1, 7!=7*6!,......*/ } 微軟Visual Studio Code編輯Java