全站数据
8 4 2 0 5 8 1

编写递归程序Java

铁建筑路人 | 教育先行,筑梦人生!         
问题更新日期:2024-05-06 06:28:51

问题描述

编写递归程序Java,麻烦给回复
精选答案
最佳答案

public class bb {public static void main(String args[]){ System.out.println(getpower(2,10));}public static int getpower(int x,int y)//此为您要的递归方法{if(y==0)return 1;else if(y==1)return x;else return x*getpower(x,y-1);} }