title: What is the origin of magic number 42, indispensable in coding?
body: <p><strong>Update:</strong><br>
  Surprised that it is being so heavily downvoted...    </p>
  
  <p>The question is <strong>coding-related</strong> and before asking this question I have googled for "42" in combination with:        </p>
  
  <ul>
  <li><strong>site:msdn.micrsoft.com</strong>   </li>
  <li>"code example"    </li>
  <li>"c#"   </li>
  <li>"magic number"  </li>
  </ul>
  
  <p>And I am not an expert/fan of Western culture/literature.   </p>
  
  <p>Also found, <a href="https://stackoverflow.com/questions/4137785/why-are-variables-i-and-j-used-for-counters/4137809#4137809">Why are variables “i” and “j” used for counters? [duplicate]</a> which was not closed but even protected.     </p>
  
  <hr>
  
  <p>I feel that everybody knows it, except me...  </p>
  
  <p>What is the origin of ubiquitous magic digit 42 used all over the code samples and samples?  </p>
  
  <p>How have you come using 42?  because I have not ever come or ever used <strong>42</strong>  </p>
  
  <p>After some search, I found MSDN doc on it:  <a href="http://msdn.microsoft.com/en-us/library/ee621251.aspx" rel="noreferrer">Magic Numbers: Integers</a>:  </p>
  
  <ul>
  <li><strong>"Aside from a book/movie reference, developers often use this as an arbitrary value"</strong>   </li>
  </ul>
  
  <p>Well, this did not explain me anything.   </p>
  
  <p>Which movies and books have I missed for all those years of being involved  in development, coding and programming and around-IT related activities like rwquirements analysis, system administration, etc??   </p>
  
  <h1>Some references to some texts using code snippets with 42 (just C#-related):</h1>
  
  <p>Jérôme Laban. <a href="http://www.jaylee.org/post/2012/09/29/C-Async-Tips-and-Tricks-Part-3-Tasks-and-the-Synchronization-Context.aspx" rel="noreferrer">C# Async Tips and Tricks, Part 3: Tasks and the Synchronization Context</a> </p>
  
  <pre><code>  var t = Task.Delay(TimeSpan.FromSeconds(1))
                .ContinueWith
                  (
                      _ =&gt; Task.Delay(TimeSpan.FromSeconds(42))
                  );
  </code></pre>
  
  <p>MSDN <a href="http://msdn.microsoft.com/en-us/library/dd492627.aspx" rel="noreferrer">Asynchronous Agents Library</a></p>
  
  <pre><code>   send(_target, 42);  
  </code></pre>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/jj220067.aspx" rel="noreferrer">Quickstart: Calling asynchronous APIs in C# or Visual Basic</a></p>
  
  <pre><code>  Office.context.document.setSelectedDataAsync(
        "&lt;html&gt;&lt;body&gt;hello world&lt;/body&gt;&lt;/html&gt;",
         {coercionType: "html", asyncContext: 42},
         function(asyncResult) {
             write(asyncResult.status + " " + asyncResult.asyncContext);
  </code></pre>
  
  <p><a href="http://msdn.microsoft.com/en-us/magazine/hh781020.aspx" rel="noreferrer">Asynchronous Programming in C++ Using PPL</a></p>
  
  <pre><code>  task&lt;int&gt; myTask = someOtherTask.then([]() { return 42; });
  </code></pre>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx" rel="noreferrer">Boxing and Unboxing (C# Programming Guide)</a> </p>
  
  <pre><code>  Console.WriteLine(String.Concat("Answer", 42, true));
  </code></pre>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/ms173154%28v=vs.80%29.aspx" rel="noreferrer">How To: Override the ToString Method (C# Programming Guide)</a>  </p>
  
  <pre><code>  int x = 42;
  </code></pre>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/aa983739%28v=vs.71%29.aspx" rel="noreferrer">Trace Listeners</a></p>
  
  <pre><code>  // Use this example when debugging.
    System.Diagnostics.Debug.WriteLine("Error in Widget 42");
    // Use this example when tracing.
    System.Diagnostics.Trace.WriteLine("Error in Widget 42");
  </code></pre>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/vstudio/6373h346.aspx" rel="noreferrer">|| Operator (C# Reference</a></p>
  
  <pre><code>  // The following line displays True, because 42 is evenly  
    // divisible by 7.
    Console.WriteLine("Divisible returns {0}.", Divisible(42, 7));
  
    // The following line displays False, because 42 is not evenly 
    // divisible by 5.
    Console.WriteLine("Divisible returns {0}.", Divisible(42, 5));
  
    // The following line displays False when method Divisible  
    // uses ||, because you cannot divide by 0. 
    // If method Divisible uses | instead of ||, this line 
    // causes an exception.
    Console.WriteLine("Divisible returns {0}.", Divisible(42, 0));
  </code></pre>
  
  <p>WIKIPedia <a href="http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29" rel="noreferrer">C Sharp (programming language)</a></p>
  
  <pre><code>  int foo = 42;         // Value type.
  </code></pre>