Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- result = []
- #Core #
- for idx, val in enumerate(range(1, 100)):
- if (idx <= 0):
- result.append(idx + (idx + 1)) #Init the first number#
- else:
- result.append(idx + result[idx - 1])
- #Testing#
- testRef = [1,2,4,7,11,16,22]
- for idx, val in enumerate(testRef):
- if result[idx] != val:
- print('Failed on test index ' + str(idx) + ' where it should be ' + str(val) + ', but there is ' + str(result[idx]))
- exit(0)
- break
- #Showing Result#
- print('Displaying result:')
- for i in result:
- print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement