How to Make a List of Numbers that Sum to n(n-1)/2

后端 未结 0 815
北恋
北恋 2020-12-01 10:06

I need to come up with an array of n integers, ranging from 0 to n-1 such that the sum of all of them is n(n-1)/2. How should I do this?

One way that I tried doing it

相关标签:
回答
  • 消灭零回复
提交回复
热议问题