r/learnquant • • 4d ago

interview prep Quant Interview Question

Post image
57 Upvotes

20 comments sorted by

View all comments

1

u/A_BagerWhatsMore 4d ago

So 100x99+98x97…

Is there a way to speed that up?

Two copies 100^2 +98^2… is 100+98… too big

99^2+97^2… is 99+97… too small
Add them together and 2x+50=sum of first 100 squares.

So x= (sum of first 100 squares -50)/2

sum of squares is what n(n+1)(2n+1)/6? (Yes)

So ((100(101)(201)/6)-50)/2) which I would need paper for.

1

u/PsychologicalLie2163 4d ago

I've not thought too deeply about it but could you use factorials?

If n=100, then 100x99 is the same as n! / (n-2)!. Then I guess you sum over all even integers between 1 and n?