I was asked this in an interview.
We have people numbered from one to infinity: $$1, 2, 3, 4, 5, 6, 7, 8, \dotsc\,.$$ In first pass every 2nd person is killed, so we have $$1, 3, 5, 7, 9, 11,\dotsc$$ remaining. In next pass every 3rd remaining person in killed. Now we have: $$1, 3, 7, 9, 13, \dotsc\,.$$ This goes on and on. Given their number in line we need to tell if the person survived.
I couldn't come up with a better than a brute force solution. I was specifically told to use programming but math based ideas are also welcome. The brute force solution was to have Boolean array of size $N$ and $\log N$ passes for all $N$ elements to mark every $k$th non marked element true. If $N$ gets marked return false else in the end return true.
Take the number, and if it is divisible by 2: dead. Else subtract the number of elements before it that were deleted (1/2 the number). Divisible by 3: dead. Else subtract the number of elements before it that were deleted (1/3 the number). Once the number is less than the number you are dividing by, it is safe.
The trick is to realize that you don't need to preserve the original value, just its place in the sequence.
Sample code (C++):
EDIT: Included code for clarity (and since original question mentioned a programming answer)