Advertisement
Guest User

rainci

a guest
Nov 7th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. result = []
  2.  
  3. #Core #
  4. for idx, val in enumerate(range(1, 100)):
  5.     if (idx <= 0):
  6.         result.append(idx + (idx + 1)) #Init the first number#
  7.     else:
  8.         result.append(idx + result[idx - 1])
  9.  
  10. #Testing#
  11. testRef = [1,2,4,7,11,16,22]
  12.  
  13. for idx, val in enumerate(testRef):
  14.     if result[idx] != val:
  15.         print('Failed on test index '  + str(idx) + ' where it should be ' + str(val) + ', but there is ' + str(result[idx]))
  16.         exit(0)
  17.         break
  18.        
  19. #Showing Result#
  20. print('Displaying result:')
  21. for i in result:
  22.     print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement