There needs to be some formula else it’s a bad question
For every n, which is a power of 2, always 1 will win.
For any n;
write n = 2^m + k;
where m is largest possible power for k to be greater than or equal to 0.
Answer will be 2k+1
e.g. n = 100;
n = 2^6 + 36;
ans = 236+1 = 73
The person holding the sword when 2^N people are remaining will survive the last. When 64 people are remaining (i.e. 36 people dead), sword is with the 73rd person, so he survives last.