Which number remains alive? There are $100$ people standing in a circle numbered from $1$ to $100$. The first person is having a sword and kills the the person standing next to him clockwise i.e $1$ kills $2$ and so on. Which is the last number to remain alive? Also if $1$ kills both the person standing next to him. Which is the last number standing? Can both of them be generalized?

this can be solved using mathematics of induction.

winner=(total_people - (2^i - 1 - total_people))

here i can be calculated using this equation: 

2^i <= total_people < 2^(i+1)

Here's the c++ implementation:
#include<iostream>
#include<cstdio>
#include<math.h>

using namespace std;

int main(void)
{
    int i,total_people;

    while(true){
        cin>>total_people;
        i=0;
        while(pow(2,i)<=total_people){
            i++;
        }
        i--;
        int winner=(total_people-(pow(2,i+1)-1-total_people));
        cout<<winner;

    }

}

