python 简单实现阶乘与幂方

来源:互联网 发布:女装淘宝网店推荐 编辑:程序博客网 时间:2024/05/01 16:42
最近刚开始学python,先试着从一些简单运用开始吧!#coding-utf-8import math#实现各阶次方运算def power(x,n):    s=1    while n>0:        s=s*x        n-=1    return s#实现阶乘运算def jiecheng(x):    a=1    while(x):        a=a*x        x-=1    return aprint jiecheng(input(":"))print power(input("输入底数:"),input("输入次幂:"))