public class Digui { public static void main(String[] args) { System.out.println(f(1)); } public static int f(int n){ if (n==5){ return 1;} else{ return 2*f(n + 1) + 2; } } }
java猴子吃桃问题,猴子每天吃一半桃子之后,觉得不够过瘾又吃一颗桃子,长此反复,到第五天时只剩下1颗桃子,问猴子第一天有多少颗桃子?
最新推荐文章于 2024-07-11 17:24:34 发布