There's a fun game I like to play called "Spot the Saturday Night Live Alum." It's a simple game, usually played when I'm watching a TV show or movie and suddenly think, "Was Billy Murray on Saturday Night Live or was he just friends with everyone who was?" (Answer: Of course he was. It's his Caddyshack director and Ghostbusters co-star Harold Ramis who wasn't.)

The game can be trickier than you'd think. Who on Showtime's Shameless came from SNL? That would be Joan Cusack, a cast member for one season in the 1980s. Anthony Michael Hall connects the show to pretty much every 1980s teen movie. Steve Higgens, Jimmy Fallon's Tonight Show announcer and the inspiration for the character of Andy Dwyer on Parks and Recreation, is a former writer. This is more intimate than the Six Degrees of Kevin Bacon game—it's more like the Four Degrees of Lorne Michaels.

When Saturday Night Live starts its 40th season on Sept. 27, it will have been on the air for 39 years. It's one of the longest-running programs in television history, certainly the longest-running weekly comedy program. SNL is broadcast in more than 200 countries. Films starring its cast members have brought in more than $66.5 billion at the box office.

None of this is an accident. While Saturday Night Live may look like a bunch of Land Shark and Dick-in-a-Box jokes, it's an incredibly efficient comedy machine. "The tremendous number of successful graduates of the SNL academy of comedy is a testament to the excellence of the system they have for auditioning people and putting them on the show," says Tom Shales, a Pulitzer Prize-winning former Washington Post television critic and co-author of Live From New York: An Uncensored History of Saturday Night Live. It's not a particularly rigid or scientific system, of course—comedy requires freedom and casualness in order to flourish. But over the years, creator Lorne Michaels and his team have honed a system of scouting talent, working that talent to the bone, and then making sure they leave before they have a chance to grow too comfortable.

Before SNL can foster the Eddie Murphys and Tina Feys of the world, it has to find them. The show's talent scouts famously draw from improv comedy troupes such as Chicago's Second City and Los Angeles's Groudlings, but they scour dingy comedy clubs too. Molly Shannon was working as a waitress before she was hired—she's now one of SNL's more successful stars; her movies have collectively made more than $2.1 billion. "Lorne has a knack for spotting talent from a mile away," says Shales. In the 1970s, Michaels watched a comic named Alan Zweibel bomb in a nearly empty club, asked to see some jokes he's written, and then hired him as a writer. It's a good thing, too: Zweibel wrote John Belushi's "Samurai" skits and helped Gilda Radner create Roseanne Roseannadanna. So what if he couldn't do stand-up to save his life?

In the early days, most cast members arrived at SNL already knowing each other (Dan Aykroyd and Gilda Radner dated when they were at Second City), and Michaels made several hiring decisions based on their recommendations. Bill Murray's younger brother Brian Doyle-Murray even spent a few years on the show—a fact that'll come in handy if you play the "Spot the SNL Alum" game the next time you watch As Good As It Gets.

But if SNL's hiring technique is a magical combination of nepotism and instinct, what happens once people get to the show seems more like an old-fashioned boot camp. Workdays can run until 4 a.m., if not later. It's such a demanding job that, according to the New Yorker, in the early 1970s writers and cast members had bunk beds installed so they could get some sleep. (They also did a lot of drugs and slept with each other.)

"That breakneck pace [adds to] the mystique a little bit," Jason Sudekis explained during a talk at the 2011 New York Television Festival, "There are so many things that are done there that are counter-intuitive to people that have worked other places." When Larry David tried to go home at 7 p.m. one night, Dick Ebersol, who temporarily became the show's producer in the show's seventh season, stopped him. "I got in the elevator and left," David later recalled. "I think that was the beginning of the end for me." Ebersol often cut David's skits from the show and he lasted as a writer for only one season.

But a lot of writers and actors thrive on Saturday Night Live's intensity, so much so that sketch comedy can start to feel limiting—both creatively and financially—and they eventually leave to do more. "The advice I give most often is: Build a bridge to the next thing. When it's solid enough, walk across it," Michaels told in February. SNL's tradition of continually tweaking, rotating, and sometimes overhauling its cast started in 1976 with Chevy Chase, who left the show six episodes into the second season. Each time an Amy Poehler moves out and a Kate McKinnon moves in, the show's comedy is free to evolve. This is how Saturday Night Live has been able to grow from an amped-up Belushified frat party into a mainstream television juggernaut.

Not every change is seamless, nor every cast member so easily replaced. Comedy is an imperfect system and sometimes even the best jokes bomb. The cast will come back the next week, stay up a little too late, work a little to hard, and do it all over again.