As fans of the show can attest, Silicon Valley ended its first season (now available on Blu-ray) with the greatest dick joke in TV history. Not only was the whole elaborate thing brilliantly hysterical, but it was also mathematically sound thanks to the show’s technical advisers. To recap how the show got to this point: the finale brought us to TechCrunch Disrupt, where the Pied Piper team was poised to present their impressive compression algorithm, but they were quickly scooped by the ever-powerful Gavin Belson, who presented a compression speed (coined on the show as the Weissman Score) equal to the one Pied Piper was set to present. Belson warns the audience, “Anyone who tells you their platform is faster than ours better have good lawyers.” Erlich (T.J. Miller) then encourages the deflated team to not give up, declaring, “We’re going to win, even if I have to go into the auditorium and personally jerk off every guy in the audience.” Retreating to their hotel room, the boys of course devise equations on how to most efficiently jerk off all the men in the audience, in what was regarded as Optimal Tip-to-Tip Efficiency. (Following the episode one of the show’s research consultants released a written study that goes into greater detail on the math involved in this highly researched joke.) Through their rigorous calculations, Richard reaches an epiphany. The answer is in middle-out, of course. He goes on to create the highest Weissman Score ever. I spoke with show creator Mike Judge; writer/director Alec Berg; associate producer Jonathan Dotan; actors T.J. Miller, Kumail Nanjiani, and Zach Woods; Stanford researcher Tsachy Weissman; and a show consultant who asked to remain anonymous over fears that his primary employer would frown upon him playing a part in the creation of the greatest dick joke ever told on television. Killed at the first table read HBO was really happy. It’s almost the opposite of a regular network. KUMAIL NANJIANI (Dinesh): When I first read that joke — we did a table read for it — and right there, it was awesome. It did really well at the table read. The HBO execs were there, and it just felt like something pretty special and something I hadn’t seen before. MIKE JUDGE (Creator/Executive Producer): We wanted to have a moment like in A Beautiful Mind, where there’s this epiphany based on a real life thing, which is something that’s more silly, and it wound up being a dick joke. ZACH WOODS (Jared Dunn): I immediately wrote a letter to HBO because my feeling is that there are things to be joked about and things not to be joked about. And I think sex — and dicks in particular — are not a joking matter. So, I protested pretty aggressively. But they insisted that I participated […] No, that’s not true! That’s not true! I’d be the biggest asshole. I loved it. JUDGE: HBO was really happy. It’s almost the opposite of a regular network. Here, we don’t have any nudity, any love scenes. Finally, at least, there’s a long dick joke. It was almost this concern that we’re not nasty enough in the show to make it an edgy pay cable show.

ALEC BERG (Executive Producer/Writer): There is no nudity on our show. Nobody’s having sex. There’s more sex in one scene of Game of Thrones then there will be in five seasons of our show. T.J. MILLER (Erlich Bachmann): I thought it was likely going to be the greatest joke in the history of American comedy. That was ambitious, but eventually, we came to find out that it was the greatest dick joke in the history of American, French, British and Sri Lankan comedy. WOODS: I thought it was brilliant and encapsulated so much of what I liked about the writing up until that point in the season, which is that it was the smartest dumb thing and the dumbest smart thing. And also it was emotionally realistic in a way. NANJIANI: What was cool about it is it worked in so many ways. It was a hilarious joke, but it is also a big moment in the season for the story. It’s funny, but also it’s a pretty important plot point and turning point for the emotionality of the Richard character. MILLER: [At the table read] there was a lot of pausing and laughing and mutterings of “holy shit” and “that’s so funny” and “did anyone eat the rice pilaf? It’s in-fucking-credible.” We were so excited and the food was delicious. WOODS: It’s really more of a logic joke then a dick joke. It’s like a logic joke with dick specifics. You’re just trying to solve a problem and it just happens to be about how fast you can make two guys cum or four guys, depending on whether or not you’re using both hands. JUDGE: One of many things I liked about it, it’s all our guys solving a problem together. And so they’re all pitching in. So, Erlich, Jared, nobody is fighting over anything. Those are warm, cuddly, season ending moments. MILLER: People loved it. I’m so happy because that’s the only reason I do the show, for the people who love it. I also do it for the people who hate it, but I don’t like them.

WOODS: The other day, I was leaving The Container Store, where I was buying some hangers and the guy in the parking lot was like, “Hey, man. What’s your D to F?” Which is dick to floor. Then he’s like, “What do you think the mean jerk time is in this area?” He didn’t say hi or anything. MILLER: I get a lot of people after stand-up shows or in airports conspiratorially asking me, “Pssst. How long do you think it would take you to jerk off everyone in this room?! LOL,” or “Hey, what’s your D2F?! LOL HAR HAR! Seriously how far away from the floor is your dick?” WOODS: I said, “Well, I think that the area is probably pretty affluent, so I think people are probably a little healthier here and they have access to better nutrition and exercise. So my guess is the mean jerk time would be slightly longer.” I said that, but I don’t know if health correlates with actual prolonged sex. I don’t know if that’s true, if healthy people take longer. But that’s what I said. I tried to answer honestly. But then I got lost in my own stupid logic. The ridiculously extensive research I was always so confused why they were obsessed with this phrase middle-out. And then Jonathan finally shared the script with us for the final scene. I sent it to Tsachy and told him, ‘This is the most surreal thing I’ve ever been asked to do.’ Early on in the creation of the show, Judge, Berg and Dotan sought out two technical consultants to assist with the show’s technical and mathematical accuracy. Little did these consultants know that, by the season’s end, their knowledge and research would be instrumental in the season finale’s sophisticated dick joke. One of these researchers has chosen to remain anonymous throughout this oral history and will henceforth be known simply as “Anonymous Consultant.” JONATHAN DOTAN (Associate Producer): The initial genesis of all this actually came by looking at the history of compression. We called up [Tsachy] Weissman to have him come up with the real science behind this. He was super confused when I called him. He was like, “So you’re calling from HBO and your doing a television show about compression? Are you kidding me?” ANONYMOUS CONSULTANT: [Tsachy Weismann] knew I had an interest in film and theatre, and I was also working on data compression and information theory. So, when he got contacted by HBO, he early on brought me into the loop. TSACHY WEISSMAN (Technical Consultant): I connected Jonathan with [Anonymous Consultant]. He showed just how proficient and creative he is. Not only in the technical aspect, but throughout the show when he was working with him. He saw that he was not only this geek who knows compression, but he’s also very creative, and he was able to seamlessly connect between the plot and the humor of the show and the technical content. ANONYMOUS CONSULTANT: Initially, I just heard about the phrase middle-out, which comes out in the scene. And that phrase was supposed to inspire algorithms. I was always so confused why they were obsessed with this phrase middle-out. And then Jonathan finally shared the script with us for the final scene. I sent it to Tsachy and told him, “This is the most surreal thing I’ve ever been asked to do.”

JUDGE: A lot of the dialogue was from just us in the writers room talking, and I think we even drew some diagrams. But then we threw it to them to give us more stuff. And boy, did they go. I’m surprised [Anonymous Consultant] finished his PhD that year. He spent a lot of time on that. He got his PhD shortly after. WOODS: I just thought it was hilarious that they got real engineers and mathematicians to think about it. So many times, you’ll see a dick joke on TV, and you’ll think, “That’s a good joke, but I don’t buy the math of it.” In this case, just having that bullet proof scientific defense, it really gave us all the confidence we needed to go forth. ANONYMOUS CONSULTANT: I’ve been surprised by how much [talking to Judge is] not like talking to a Hollywood producer. It’s like talking to an extremely competent technical manager. He’s actually very interested in the technical side of things and will often not want to skip over them and get to the meat of stuff. He wants to dive in and understand stuff. JUDGE: When we started talking with [Anonymous Consultant], originally, the compression was something that I’d start out with because that was something I remembered from school. Hopefully it helped [Anonymous Consultant] get inspired knowing that, on our end, we would actually appreciate and understand, sometimes, what he was talking about. But, boy, he definitely got enthusiastic on that bit. ANONYMOUS CONSULTANT: If you pause during the dick joke analysis, there’s one figure on there, it’s a plot of a person’s proclivity to orgasm as a function of their age. And there’s a complicated function of their age. But I didn’t really attach too much information to these figures in the first round when I sent out the figures for them to use. I drew them out, but the crazy thing is Mike saw the figures and he actually deconstructed what that diagram was and what it meant. He broke it down. Which I was extraordinarily shocked to hear about. JUDGE: There’s a thing on the white board, this metric for stamina, that Kumail was asking me, “Hey, what is this I’m pointing to?” And then I start looking at it and figuring it out and then I was like, “Whoa, this actually makes sense and is actually interesting.” That the graph starts at infinity because when you’re a baby you can’t ejaculate. And it dips down and gets higher around your 30s, then goes back to infinity. It all made complete sense. I suppose a little of my math background helped just so I could figure that out and explain it to Kumail. He actually has a computer science background too. Filming The Scene You know, people do peyote or they go on these fucking meditation retreats. All you really need to do is film the same dick joke for a few hours and you get to the same place. NANJIANI: We shot it in an actual hotel. It was three minutes of screen time and took us 14 hours to shoot that scene because they knew it was so important. We kept re-doing it over and over and over trying to get the tone just right. JUDGE: To me, every scene seems like it takes forever to shoot. That one, I had a feeling that this could be really good and I wanted to make sure we got it right. MILLER: While it was very funny, we were so tired, there wasn’t a lot of breaking. WOODS: We were at the end of the season, so we were all pretty punch-drunk and tired. Then, we shot that in this hotel late, late at night. I just started to feel so delirious. It’s really a transcendent experience. You know, people do peyote or they go on these fucking meditation retreats. All you really need to do is film the same dick joke for a few hours and you get to the same place. Self-forgetfulness and that connection to something greater.

NANJIANI: It’s tough because when you’re in a hotel room, it takes much much longer because the walls don’t come down, it’s not made for filming. BERG: A lot of times when you shoot things like that, you’re on a set and you can move. When you try to put a camera a certain place, you can pull a wall out or a window out and shot through it. So, you have a little bit more space and a little bit more room to move. And you can get better angles and the air conditioning is better. So, it was hot in there and it was kind of cramped. JUDGE: We had our video monitors in a room across the hall. So, anytime we’re given a note, we had to go in the other room. BERG: We kept getting locked out of that room, as I recall. JUDGE: I do remember having to knock on the door. BERG: We had keys, but some of them didn’t work. You know how hotels have these magnetic keys, and they stop working all the time? That kept happening to us. NANJIANI: We bought movies on pay-per-view, and then we’d shoot, and while they’re setting up the next shot, we would go watch the next part. We watched Red 2 and R.I.P.D., those were the movies we could all agree on. MILLER: I had been watching Red 2, so I was pumped — it’s an excellent film, great performances and quite a ride — in a hotel room, that’s saying something! So, I was jazzed from all that sweet elderly action.

WOODS: T.J., who will make a joke out of anything, was seriously and with great intention watching Red 2. His sincerity might have been a bit. But it was a very long, several hours long, joke. But I remember him turning up the volume and really digging into it while in-between set-ups. MILLER: I absolutely loved Red 2. In fact, when I met the director and producer, I teared up and almost started crying. I love that movie like I love Yogi Bear 3-D and my entire lexicon of work as a musician. Genuinely, authentically and truly… Not. A. Joke. JUDGE: I remember the actors were improvising a lot of lines. Stuff like, “Oh, are you pointing it at your mouth?” BERG: It just seemed much funnier to us that they were talking about math with absolutely no awareness at all that what they were talking about was anything but math. JUDGE: It was one of those cases where taking out every single improv made it funny, making it purely problem solving just made it funnier to us. NANJIANI: I think the one thing that they did use that was improvised was the girth thing. If different girths affect it. That was the only thing I believe that we improvised that made it in, just because it had to be so specific. It can’t be funny at all. Most of our improv is funny, that scene is only funny if it’s not funny at all to the characters. That’s the only way that scene works. MILLER: I can’t remember exact lines, but I believe I said something very pithy about being able to double fist two dicks in one hand. WOODS: I remember at one point they were asking me if Jared had ever masturbated. Definitely not on the game of the joke, but I remember I liked them asking me that. I remember in the scene him saying it was too decadent. It’s something that old French dukes would do or something. But I don’t think he has. I think he’s probably had wet dreams. But I don’t think he’s been an active participant. His wet dreams wouldn’t even be explicitly sexual. It would just be about getting a gift card to The Container Store.