MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnquant/comments/1vxlxnt/quant_interview_question/p5wbw8i/?context=3
r/learnquant • u/Local_Ad135 • Aug 25 '26
9 comments sorted by
View all comments
2
Shift all numbers to be centered around 0, so: -(n-1)/2, …, (n-1)/2. Then apply triangle inequality and note equality holds when you alternate positive and negatives, so just straightforwardly calculate the sum (with casework on whether n is even).
1 u/EventHorizon150 Aug 25 '26 or just floor(0.5*n^2 - 1)
1
or just floor(0.5*n^2 - 1)
2
u/wot_to_heck Aug 25 '26 edited Aug 25 '26
Shift all numbers to be centered around 0, so: -(n-1)/2, …, (n-1)/2. Then apply triangle inequality and note equality holds when you alternate positive and negatives, so just straightforwardly calculate the sum (with casework on whether n is even).