您的位置:首页 > 编程语言 > Python开发

python SimpleAdding

2014-04-22 16:42 309 查看
Using the Python language, have the function SimpleAdding(num) add
up all the numbers from 1 to num.
For the test cases, the parameter num will
be any number from 1 to 1000.

def SimpleAdding(num):

# code goes here

if num > 1:
return num + SimpleAdding(num-1)
else:
return 1

# keep this function call here
# to see how to enter arguments in Python scroll down
print SimpleAdding(raw_input())


Input =
12Output = 78
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: