marsさんとこで発見。すごいよこれ。
public class MyClass {
public static void main() {
// Your algorithm goes here.
System.out.println(factorial(5));
}
static int factorial(int v) {
if (v == 1) return 1;
return v * factorial(v - 1);
}
}
とか見せれば、たちどころに再帰が理解できるようになるかも。