Please read the new rule regarding the restriction on the use of AI tools. ×

henrique08061999's blog

By henrique08061999, history, 4 years ago, In English

598A- python3 from math import log2 def sum_until_n(n): return n*(n+1)/2 def sum_of_squares(n): return 2**(int(log2(n))+1)-1

m=int(input()) res=[] for i in range(m): n=int(input()) k=int(sum_until_n(n)-(2*sum_of_squares(n))) res.append(k) for v in res: print(v)

  • Vote: I like it
  • -1
  • Vote: I do not like it