I have a reward of 288 tokens (divisible to 8 decimal places) to distribute among the top 64 winners of a daily contest
I'd like this to be fair, and use equal portions so #1 (first place) gets 64 portions, #2 gets 63 portions, down to #64 that gets 1 portion.
How can I express this distribution mathematically, such that I can plug in the position of the winner and get out their reward?
If you sum tokens from 1 to 64, you will get $64×65/2=2080$ tokens which is larger than 288 you have.
However, if you allow 64-th place to receive $x=288/2080 \approx 0.138$ tokens, 63-rd place $2x=0.277$ tokens, ... and 1st place $64x=8.862$ tokens, then you will keep the prize ratio as before and the prizes will sum up to 288.
In general, the amount $k$-th place receives can be calculated as $$ p(k) = \frac{2Sk}{n(n+1)}, $$ where $S=288$ and $n=64$;