double s = 0; public double jiechen(int n, int idx) { if (idx <= 0) { return s; } s = Math.pow(n, idx) + jiechen(n, --idx); return s; }