¹þ¹þ¹þha1 ·¢±íÓÚ 2021-9-25 14:49:46

ΪʲôҪдx*power(x,y-1)¿ÉÒÔ£¬Ð´power(x,y)¾Í²»ÐУ¬ÌáʾÎÒ³¬¹ý×î´óµÝ¹éÉî¶È

def power(x,y):
    if y:
      return x*power(x,y-1)
    else:
      return 1

print(power(2,3))

ÌÓ±ø ·¢±íÓÚ 2021-9-25 14:53:03

±¾Ìû×îºóÓÉ ÌÓ±ø ÓÚ 2021-9-25 14:56 ±à¼­

Èç¹ûxºÍyûÓб仯µÄ»°£¬µÝ¹éûÓгö¿ÚÁË
¾ÍÏñ¸öËÀÑ­»·
power(2,3)¡ú2 * power(2,3)¡ú2 * 2 * power(2,3)¡ú2* 2*2*power(2,3)....

¹þ¹þ¹þha1 ·¢±íÓÚ 2021-9-25 15:01:19

ÌÓ±ø ·¢±íÓÚ 2021-9-25 14:53
Èç¹ûxºÍyûÓб仯µÄ»°£¬µÝ¹éûÓгö¿ÚÁË
¾ÍÏñ¸öËÀÑ­»·
power(2,3)¡ú2 * power(2,3)¡ú2 * 2 * power(2,3)¡ú ...

Ìý¶®ÁË£¬¸Ðл´óÀÐ
Ò³: [1]
²é¿´ÍêÕû°æ±¾: ΪʲôҪдx*power(x,y-1)¿ÉÒÔ£¬Ð´power(x,y)¾Í²»ÐУ¬ÌáʾÎÒ³¬¹ý×î´óµÝ¹éÉî¶È