Commit 40088d31 by BellCodeEditor

auto save

parent f2289e9e
Showing with 23 additions and 9 deletions
def sum_numbers(num): 1x
if num == 1: 1d
return 1 1d 1x
2d 1x
3d 2x
5d 3x
8d 5x
13d 8x
21d 13x
34d 21x
55d 34x
89d 55x
144d 89x
223d 144x
367d 223x
589d 367x
956d 589x
1545d 956x
2501d 1545x
4046d 2501x
6547d 4046x
10593d 6547x
\ No newline at end of file
result = num + sum_numbers(num-1)
return result
number = 50
res = sum_numbers(number)
print("1到"+str(number)+"和是:"+str(res))
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment