Your mileage may vary, but I think that one of the funnest math problems out there is the Problem of Josephus.
--The Problem--
You have N (where N can be any number) people standing around in a circle. Starting with an arbitrary person and going around clockwise, every other living person in the circle is killed until one person remains. For example, if you have 5 people in the circle, the 1st person is killed, then the 3rd, then the 5th, then the 4th (the 1st and 3rd people are dead, and we skip the 2nd), and the 2nd person survives.
For any circle of N people, where would you want to stand in the circle to be the last person standing.
--The Solution--
(Note: when I started working on this problem, I would draw 1, 2, 3, 4, 5... in a circle, and then cross them out while moving around the circle and mumbling "kill skip. kill skip. kill skip". For the purpose of not looking like a homicidal maniac, I strongly advise against this approach).
It's pretty simply to brute force the solution to this problem for small N. For example, if N = 1, it's obvious that there is no solution and no one survives (this is really significant, because it tells us that shifting the domain of the problem can lead to no solutions, suggesting perhaps that there is a logarithm somewhere in our answer). For N = 2, the 2nd person is the survivor. For N = 3, the 2nd person is still the survivor. For ease of reading I create this table:
2 - 2
3 - 2
4 - 4
5 - 2
6 - 4
7 - 6
8 - 8
9 - 2
There are a few interesting patterns here. The first neat one is that if N is 2 raised to an integer power, then the Nth person is the survivor (for example 2, 4, 8). Another neat thing is that the position of the survivor slowly rises until it becomes the last spot in the circle, and then suddenly depresses to the 2nd person. It also rises at a rate of 2 people for every increase in N.
If we say that k is the integer value for which (2^k) is as large as possible while still being smaller than N (so for example, if N = 9, k = 3 because 2^3 is the largest value of 2^k smaller than 9), then we can write our solution quite neatly:
p(N, k) = 2(n - 2^k)
p(2, 0) = 2
p(3, 1) = 2
p(4, 1) = 4
p(5, 2) = 2
p(6, 2) = 4
p(7, 2) = 6
p(8, 2) = 8
p(9, 3) = 2
p(10, 3) = 4
This fits perfectly with our old data, so its pretty safe to say that our formula is right. But just to make the formula more complete, we ought to find k in terms of N. We know that k is just the the largest integer that 2 can be raised to, such that 2^k is smaller than N. Writing this out a little bit more formally:
2^k < N
k is an integer
k is as large as possible, given the two previous statements
Well, if we rearrange the first statement, we get
2^k < N
log2(2^k) < log2(N)
k < log2(N)
How do we ensure that k is an integer? Simple, you ensure that N is 2 raised to some integer power. So for example if N is 9, then k is \\log2(9)// (where \\2.5// is 2, and the slashes mean floor to the greatest integer less than what's inside the slashes). The only odd thing with this is that for this to work, we have to treat \\5// as 4, while the floor function would normally treat \\5// as 5. If anyone knows what you'd actually call the greatest smaller integer function I'm describing, don't hesitate to tell me.
So substituting in k = \\ log2(N) //, we get:
p(n) = 2(n - 2 ^ \\log2(n)// )
If you try this with various suicide circles, it should become apparent that it works as intended.
It's also interesting to note that this formula can easily be generalized to describe the case where you skip more than one person at a time as you move around the suicide circle. I don't feel like trying it now, but I'm pretty sure it just becomes:
p(n, m) = m(n - m ^ \\logm (n)//)