第15433题 单选题
有关以下实现1~N求和的Python代码,说法错误的是?
#sumA()和sumB()用于求1~N之和
def sumA(N):
    ret = 0
    for i in range(1, N + 1):
        ret += i
    return ret

def sumB(N):
    if N == 1:
        return 1
    else:
        return N + sumB(N - 1)

N = int(input("请输入大于等于1的正整数:"))
print(sumA(N),sumB(N))
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析