Advertisement
max2201111

def -1000,999,-998,997

Aug 10th, 2024
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | Science | 0 0
  1. max_value = 1000
  2.  
  3. def calculate_parent_value(n):
  4.     if n == 1000:
  5.         return -999
  6.     elif n == -1000:
  7.         return 999
  8.     elif n == 0:
  9.         return 0
  10.     else:
  11.         return -(1 - 2*((abs(n) - 1) % 2)) * (abs(n) - 1)
  12.        
  13. for i in range(990,1001):
  14.     print(calculate_parent_value(i))
  15.  
  16. print(calculate_parent_value(0))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement