PTA的Python练习题(十九)
好久没写题目了,最近C语言也快忘得差不多了,要孰能生巧
1.
def fn(m, n): sum=res=0 for i in range(1, n+1): sum=sum+m m=m*10 res=res+sum return res 2. 我以为我看懂题目了,其实没有 def isPrime(num): num=int(num) for i in range(2,num): if num%i==0 : return False if(num!=1): return True def PrimeSum(a,b): sum=0 for i in range(a,b+1): if isPrime(i): sum+=i return sum
这里要定义两个函数,第二个函数算sum时候会调用第一个函数判断是否是素数
相关推荐
夜斗不是神 2020-11-17
huavhuahua 2020-11-20
Yasin 2020-11-16
xiaoseyihe 2020-11-16
千锋 2020-11-15
diyanpython 2020-11-12
chunjiekid 2020-11-10
wordmhg 2020-11-06
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16