I just watched the eighteenth episode of *Lost*, which revolves around the number sequence (4, 8, 15, 16, 23, 42). I looked around on the net and found that someone had discovered that the polynomial P(x) = (1/40)(-9x^5 + 125x^4 - 585x^3 + 1075x^2 - 446x + 160) generates this sequence for x = (0, 1, 2, 3, 4, 5).

How did this person discover this polynomial? Is there some algorithm which takes a finite integer sequence (s_0, s_1, …, s_n) and returns a polynomial P(x) producing that sequence for x = 0 through n?

Note: I haven’t watched the rest of *Lost* yet. Please don’t spoil it for me by telling me what the numbers mean.