[Question]
  [
**Locked**. This question and its answers are [locked](/help/locked-posts) because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
 
 
[Douglas Adams](https://en.wikipedia.org/wiki/Douglas_Adams) was born on March 11, 1952, and died when he was just 49. In honor of this wonderful writer, I challenge you to display [42](https://en.wikipedia.org/wiki/Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#The_number_42) in the most creative way possible.
You could print it in the log, via some convoluted method, or display it as ASCII art, or anything! Just come up with a creative method of displaying 42.
Because this a popularity-contest, whichever answer has the most upvotes by March 11, will be declared the winner. 
**Note:** this is not a duplicate. The question it was marked as duplicating was a code-trolling question whose goal was to write code to output 42, not find the most creative way to *display* it.
## **Winner:** grovesNL! With an astounding 813 votes! Congrats!
## Honorable Mentions:
[Mr Lister](https://codegolf.stackexchange.com/a/21887/16874) **C** 228 For the clever use of #define
[David Carraher](https://codegolf.stackexchange.com/a/21911/16874) **Mathematica** 45 For the complicated and convoluted math function to achieve 42
[Aschratt](https://codegolf.stackexchange.com/a/22081/16874) **Windows Calculator** 20 Because, well, *it's windows calculator* And definitely 1337.
[f.rodrigues](https://codegolf.stackexchange.com/a/22254/16874) **Python** 17 Because of the clever use of using external programs. And *MSPaint*
[Jason C](https://codegolf.stackexchange.com/a/21944/16874) **LMGTFY** 14 For the use of LMGTFY (Let Me Google That For You)
[Trimsty](https://codegolf.stackexchange.com/a/22417/16874) **Python** 12 For the clever use of an error message to output 42.
[Mukul Kumar](https://codegolf.stackexchange.com/a/21895/16874) **C++** 7 For the nice ASCII output.
If you think that there is another answer worth putting on the list, please comment it! 
  
[Answer]
# Double Brainfuck
```
           +++++[>++[>+>+        ++>++++>++++>++++>++++++
          >++++++>+++++++        ++>+++++++++<<<<<<<<<-]>>
         >+>+>+> >>>+[<]<        -]>>       >++>-->>+>>++>+
        >--<<<<  <<<.....         .>            ....<......
       ...>...   <<.>....                       >.>>>>>.<.
       <<<<..     ..<....                      >..>>>>>.<
      .<<<<.      >>>.<<.                     >>>>>.<.<
      <<<<<       <.>...>                    >>>.>>>.
     <<<.<        <<<..>>                  .>>>>>.<
    <.<<<         <<...>>                 >>>.<<<
   <..<.          ...>...               <<.>..>.
   >>.<.<<...>>...<<...>>...<         <....>>..
  .<<<.>.>>..>.<<.......<....        .....>...
                 <<.>...            .....>...
                 <......           .>>>.<<..
                 <<.>...          .....>...<......>.>>.<.<<<
                 .>......        ..>>...<<....>>.....>.<..>.
```
which outputs...
```
      ++++         +++
    +[>++++    ++[>+<-][
   <]<  -]>   >++    +++
  +.-   ---   ---    ---
 --.+++++++         +++
        +++       .++
        +++      +.-
        ---    -----.--.
```
which outputs...
```
6*7=42
```
[Answer]
# C
Here's an oldie but goodie...
```
#include <stdio.h>
#define six  1+5
#define nine 8+1
int main()
{
    printf("what do you get when you multiply six by nine?\n");
    printf("%i x %i = %i\n", six, nine, six*nine);
}
```
This program contains 42 different ASCII characters.
[Answer]
## Brainfuck
Took a while to get there, but I like the result:
```
         +++++          +++[>+>++>
        +++>++        ++>+++++>+++++
       +>+++++       ++>+        ++++
      +++ >+++       ++++        ++>+
     +++  ++++                   ++>+
    +++   ++++                  +++>
   +++    ++++                 ++++
  +>+     ++++               ++++
 +++      +>++             ++++
++++++++>+++++++++       ++++
++>+++++++++++++++     +<<<
          <<<<        <<<<
          <<<<       <-]>
          >>>>       >>----.++++<<<<<
          <<>>       >>>>++.--<<<<<<.
```
When run, it will print 42, of course.
[Answer]
# JavaScript:
```
var ________ = 0.023809523809523808, ____ = 1, ___ = 0, __ = 0, _ = 1;
       __ -           ___
     /_  |0        //     \\
    /_/   0     //          \\
   /_/_  |0                //
  /_/_   |0              //
 /_/____ |_           //
/________|0        //
         |0     //______________
```
The output is:
> 
>  **42**
> 
> 
> 
*Not bad, eh?* :)
***For the people who don't understand, it actually evaluates the following:***
> 
>  
> ```
> __ - ___ / _ | 0 / _ / 0 / _ / _ | 0 / _ / _ | 0 / _ / ____ | _ / ________ | 0 | 0
> ```
> 
> 
> 
> 
[Answer]
# C, Twelve Days of Xmas Style
New version:
```
main(Z,_){Z?(_=Z[" $X,X3Y<X@Z@[<XHZHX,"
"` \\(Z(X0Z0Z8[@X@^8ZHZHX(Z(`#Y(Z(X3[8"
"\\@_8ZHXHXHX(Z(` \\(Z(X0Z0Z8\\@_8ZIXI"
"X(Z(` \\,X0Z0Z8\\@_8ZHZHX,"])?main(0,_
-32),main(Z+1,_):0:(putchar((_>>3)["kt"
"wy~|tE/42"]-37),(_&7)?main(0,_-1):0);}
```
Output:
```
FFFFF OOOOO RRRR  TTTTT Y   Y    TTTTT W   W OOOOO
F     O   O R   R   T    Y Y       T   W   W O   O
FFFF  O   O RRRR    T     Y        T   W W W O   O
F     O   O R   R   T     Y        T   WW WW O   O
F     OOOOO R   R   T     Y        T   W   W OOOOO
```
By the way, also check out my [text-to-speech](https://codegolf.stackexchange.com/a/22103/16504) answer.
---
**Original Version:**
```
main(c,z,_){c==1?main(c+1,0,c^c):c==2?
z=_["##$#%&#%#x'%%()&(%%x$%$((&(*%x'%"
"%((&(+%x'#%((&(%#x"],z?z=='x'?main(4,
_,c*5):main(c+1,z,0),main(c,z,_+1):0:c
==3?(_-2)==3?main(_-1,_,32):(main(c+1,
c,((2+c)*(z-35)+_)["six*nine= {   }  "
"   ;      _   ( ) [ 3 ]do {;=0xDA"]==
32?32:043),main(c,z,_+1)):putchar(_);}
```
The output is:
```
##### ##### ####  ##### #   #       ##### #   # #####
#     #   # #   #   #    # #          #   #   # #   #
####  #   # ####    #     #           #   # # # #   #
#     #   # #   #   #     #           #   ## ## #   #
#     ##### #   #   #     #           #   #   # #####
```
Alternate spacing, if you're feeling tacky:
```
        main(c     ,z,_){c==01?
       main(c+     1,0,c^c):c==2
      ?z=_["#"     "#$#%&#%#x'%%"
     "()&(%%x"             "$%$("
    "(&(""*%x"             "'%%("
   "(&(" "+%x"             "'#%("
  "(&("  "%#x"             ],z ?z
 =='x'?main(4,_     ,c*5):main(c
 +1,z,0),main(c    ,z,_+1):00:c
 ==3?(_+-2)==3?    main(_-1,_,
         32):(     main(
         c+1,c     ,((2+
         c)*(z     -35)+
         _)[""     "six"
         "*ni"     "ne= {   }   "
         "  ;"     "      _   ( "
         ") ["     " 3 ]do {;"]==
         32?32     :043),main(c,z
         ,_+1)     ):putchar(_);}
```
The program is a single recursive statement. I made it in the style of my favorite obfuscated C program ever, [Twelve Days of Christmas](http://www.cise.ufl.edu/~manuel/obfuscate/xmas.c) (compile, prepare mind to be blown, run).
---
## HOW TO
Also, since this seems as good a place as any, here is a guide describing how to make this type of program. *This guide uses the original version above as an example.* Aside from the first bit with the block letters, they are general steps:
**INITIAL:** First, I started by making the block letters:
```
##### ##### ####  ##### #   #       ##### #   # #####
#     #   # #   #   #    # #          #   #   # #   #
####  #   # ####    #     #           #   # # # #   #
#     #   # #   #   #     #           #   ## ## #   #
#     ##### #   #   #     #           #   #   # #####
```
I then made a numbered list of the unique patterns in each 5-column character row:
```
0: *****  
1: **** 
2: *   * 
3:       
4: *     
5:   *   
6:  * *  
7: * * * 
8: ** ** 
```
And so each of the 5 pixel rows of text becomes a series of 9 numbers:
```
00000 00000 11111 00000 22222 33333 00000 22222 00000
44444 22222 22222 55555 66666 33333 55555 22222 22222
11111 22222 11111 55555 55555 33333 55555 77777 22222
44444 22222 22222 55555 55555 33333 55555 88888 22222
44444 00000 22222 55555 55555 33333 55555 22222 00000
```
For obfuscation (and ease of programming) we add the '#' character to the numbers. In the program below, `patterns` is the array of pixel patterns, and `lines` is the obfuscated array of pattern codes for each line, terminated by an 'x'. For further obfuscation we define "on" pixels in `patterns` to be any character that isn't a space; this lets us put more misleading text in `pattern`:
```
#include <stdio.h>
char pattern[] = 
  "six*n"
  "ine= "
  "{   }"
  "     "
  ";    "
  "  _  "
  " ( ) "
  "[ 3 ]"
  "do {;";
char lines[] =
  "##$#%&#%#x"
  "'%%()&(%%x"
  "$%$((&(*%x"
  "'%%((&(+%x"
  "'#%((&(%#x";
void printpattern (char c) {
  int n;
  for (n = 0; n < 5; ++ n)
    putchar(pattern[5*(c-'#') + n]==32?32:'#');
  putchar(' ');
}
int main () {
  char *ptr = lines;
  while (*ptr) {
    while (*ptr != 'x')
      printpattern(*(ptr++));
    putchar('\n');
    ++ ptr;
  }
}
```
**STEP 1:** The next step involves a few tasks:
* Remove all loops and use recursion.
* Change all functions (except main) to the form `int function (int, int)` and use the same parameter names for each. The reasons will become clear later.
* Change `main` to the form `int main (int, int, int)` and name the last two parameters the same as your function parameter names.
* Replace all references to string constants with the strings themselves; and use each string only once if possible.
* The include can be removed; it's unnecessary for `int putchar (int)`.
We can also take advantage of the weird C feature where `a[b]` is equivalent to `b[a]` to obfuscate further.
```
int printpattern (int z, int _) {
  if (_==5)
    putchar(' ');
  else{
    putchar((5*(z-'#') + _)["six*nine= {   }     ;      _   ( ) [ 3 ]do {;"]==32?32:'#');
    printpattern(z, _+1);
  }
  return 0;
}
// z ignored, _ is index
int printtext (int z, int _) {
  z = _["##$#%&#%#x'%%()&(%%x$%$((&(*%x'%%((&(+%x'#%((&(%#x"];
  if (z) {
    if (z == 'x')
      putchar('\n');
    else
      printpattern(z, 0);
    printtext(z, _ + 1); // first parameter arbitrary
  }
  return 0;
}
int main (int c, int z, int _) {
  printtext(0, 0);
}
```
**STEP 2:** Next, make use of the `?:` and `,` operators to transform each function into a single `return` statement. I'm illustrating this separately from the above because this is where things start getting confusing to look at. Remember that `putchar()` returns an `int`, and `?:` takes precedence over `,`:
```
int printpattern (int z, int _) {
  return _==5 ?
    putchar(' ')
  :
    (putchar((5*(z-'#') + _)["six*nine= {   }     ;      _   ( ) [ 3 ]do {;"]==32?32:'#'),
     printpattern(z, _+1));
}
// z ignored, _ is index
int printtext (int z, int _) {
  return
    z = _["##$#%&#%#x'%%()&(%%x$%$((&(*%x'%%((&(+%x'#%((&(%#x"],
    z ?
      z == 'x' ?
        putchar('\n')
      :
        printpattern(z, 0)
      ,
      printtext(z, _ + 1)
    :
    0;
}
int main (int c, int z, int _) {
  printtext(0, 0);
}
```
**STEP 3:** Ok. The next step is a big one. All of the functions are now a single statement of the same form. We can now combine them all into a single function, identifying each one by a number -- essentially turning the entire program into a single recursive function. Note that the first parameter to `main` will be 1 when the program is run with no arguments, so that should be our initial state. 
Also, since our parameter `c` to `main` is our state variable, we know its value at all times, and we can obfuscate a little further by replacing integer constants with their values in terms of `c` (for example, when we know `c` is 2, we can replace 5 with `c+3`). Other little obfuscations can be done too (e.g. I replaced `'#'` with `35` and `043`):
```
int main (int c, int z, int _) {
  switch (c) {
  case 1: // main
    return main(c+1, 0, c^c); // (2, 0, 0)
  case 2: // printtext
    return
    z = _["##$#%&#%#x'%%()&(%%x$%$((&(*%x'%%((&(+%x'#%((&(%#x"],
    z ?
      z == 'x' ?
        putchar('\n')
      :
        main(c+1, z, 0) // c+1==3
      ,
      main(c, z, _ + 1)
    :
    0;
  case 3: // printpattern
    return (_-2)==3 ? // _==5
    putchar(' ')
    :
     (putchar(((2+c)*(z-35) + _)["six*nine= {   }     ;      _   ( ) [ 3 ]do {;"]==32?32:043),
     main(c, z, _+1));
  }
}
```
**STEP 4:** Finally, remove the `switch` block by using a series of `?:` operators. We can also remove the `int` declarations, since C will use them by default, as well as the `return` itself (which will generate a warning at worst). After this, our program is a single, recursive function with one statement. Pretty cool, right?
Edit: I replaced `putchar()` with a `main` and `c==4` below; because I just thought of it at the last minute:
```
main (c, z, _) {
  c == 1 ?
     main(c+1, 0, c^c)
  : c == 2 ?
    z = _["##$#%&#%#x'%%()&(%%x$%$((&(*%x'%%((&(+%x'#%((&(%#x"],
    z ?
      z == 'x' ?
        main(4,_,c*5)
      :
        main(c+1, z, 0) 
      ,
      main(c, z, _ + 1)
    :
    0
  : c==3 ?
    (_-2)==3 ? 
    main(_-1,_,32)
    :
    (main(c+1,c,((2+c)*(z-35) + _)["six*nine= {   }     ;      _   ( ) [ 3 ]do {;"]==32?32:043),
      main(c, z, _+1))
  : // c==4
    putchar(_);
}
```
If you want to add a little flair, you can use more interesting numbers for `c` and even base the checks off of other numbers (e.g. for the `c==2` case, `z` is ignored and available, so instead of calling `main(2,z,_)` you could call `main(-97,_,_)` and replace `c==2` with `c<-z`). Be creative; the possibilities are endless.
**FINISH:** The final step, then, is to arrange the text in some creative pattern, and voila! You can adjust the code a little to help with formatting (e.g. I added some extra data at the end of the `patterns` string in the posted program to help get the line length right). [The ladies are sure to be all up ons.](http://www.homestarrunner.com/sbemail122.html)
[Answer]
I'm feeling lazy.
# Python
```
t
h
e
a
n
s
w
e
r
t
o
l
i
f
e
t
h
e
u
n
i
v
e
r
s
e
a
n
d
e
v
e
r
y
t
h
i
n
g:
```
Output:
```
  File "golf.py", line 42
    g:
     ^
SyntaxError: invalid syntax
```
[Answer]
# Java
**(or C++, the code's almost similar)**  
Using String functions, so don't forget to include your library!
P.S. I know it's lengthy, but it's supposed to be creative, right? And anyway, it isn't a "lowest-byte-wins".
```
String s = "Hitchhiker's Guide to the Galaxy";
String s2 = "Don'tPanic";
String s3 = "The Restaurant at the End of the Universe.";
int arthur_dent = s.length();
int ford_prefect = s2.length();
int zooey_deschanel = s3.length();
int vogon_poetry = arthur_dent + ford_prefect;
System.out.println("         " + vogon_poetry + "       " + zooey_deschanel + " " + zooey_deschanel); //in case you're confused, I'm using Zooey to print the big '2', and Vogons to print the big '4'.
System.out.println("       " + vogon_poetry + vogon_poetry + "     " + zooey_deschanel + "     " + zooey_deschanel);
System.out.println("     " + vogon_poetry + "  " + vogon_poetry + "    " + zooey_deschanel + "       " + zooey_deschanel);
System.out.println("   " + vogon_poetry + "    " + vogon_poetry + "            " + zooey_deschanel);
System.out.println(" " + vogon_poetry + "      " + vogon_poetry + "          " + zooey_deschanel);
System.out.println(vogon_poetry + " " + vogon_poetry + " " + vogon_poetry + " DA " + vogon_poetry + "     " + zooey_deschanel);
System.out.println("         " + vogon_poetry + "     " + zooey_deschanel);
System.out.println("         " + vogon_poetry + "    " + zooey_deschanel + " " + zooey_deschanel + " " + zooey_deschanel + " " + zooey_deschanel);
```
Here's the output:
```
         42       42 42
       4242     42     42
     42  42    42       42
   42    42            42
 42      42          42
42 42 42 DA 42     42
         42     42
         42    42 42 42 42 
```
Imagine my misery when I counted and found out that "The Restaurant at the End of the Universe" had *41* characters! :/ Sigh.
[Answer]
# Mathematica
## Take 1
With some work, I ought be able to golf this down a bit. :)
In `InputForm`:
```
answer[ultimateQuestion[Life,theUniverse,Everything]] =
  Times[Plus[-1,Limit[Power[Plus[1,Times[Complex[0,1],
  Power[n,-1],Pi]],n],Rule[n,DirectedInfinity[1]]]],Sqrt[-1]^2,
  Times[Rational[1,2],Plus[-1,Fibonacci[4]],Fibonacci[2]],
  Binomial[3,2],LucasL[4]]
```
In `TraditionalForm`:
![forty two](https://i.stack.imgur.com/6PTyv.png)
Testing:
```
answer[ultimateQuestion[Life,theUniverse,Everything]] 
```
> 
> 42
> 
> 
> 
---
## Take 2
Note: The numerals were made as follows.
* "42" was first printed on the screen in very large font, axes displayed, so that the coordinates of the key points could be identified.
* Another "4" was drawn a broad straight lines connecting the respective key points. It was superimposed on the previously drawn "4" to check for accuracy. The "2" was drawn as a BSpline curve. Some of the key points, which were now control points, had to be set in position by trial and error to get the desired curves.
* An third coordinate (always zero) was added to the line and BSplineCurve to enable 3D display.
---
```
answer[ultimateQuestion[Life,theUniverse,Everything]]  = 
 Table[With[{v = RotationTransform[θ, {0, 0, 1}][{3, 0, -.2}]},
   Graphics3D[{Thickness[.06], CapForm["Round"],
     Tube[Line[{{-67, 0, -44}, {-30, 0, -44}}], 10],
     Tube[
      Line[{{-25, 0, -12}, {-100, 0, -12}, {-52, 0, 70}, {-45, 0, 70}, {-45, 0, -43}}], 10], 
     Tube[BSplineCurve[l = {{27, 0, 52}, {27, 0, 57}, {57, 0, 85}, {113, 0, 40}, 
     {12, 0, -45}, {35, 0, -45}, {90, 0, -45}, {90, 0, -45}, {92, 0, -35}}], 10]},
     Boxed -> False, PlotRange -> 100, ImageSize -> 250, SphericalRegion -> True, 
     ViewPoint :> v, 
     PlotRangePadding -> 10]],(*{θ,0,2Pi,Pi/24},*){θ, -Pi/2, -Pi/2 + 2 Pi, Pi/24}]
Export["theMeaningOfLife.gif", answer[ultimateQuestion[Life,theUniverse,Everything]] ]
```
![take 2](https://i.stack.imgur.com/u8Iot.gif)
[Answer]
Seems appropriate:
```
grep -i "DON'T" /bin/lesspipe | wc -l ; grep -i "PANIC" /usr/share/pyshared/mx/Log.py | head -n 1 | cut -d '=' -f 2 | tr -d ' '
```
Output: 
```
4
2
```
Ubuntu 12.04, 64-bit Desktop
[Answer]
## Windows calculator
Multiplying **Pi** with **13.37** and ignoring the decimal `:P`
![Forty-Two](https://i.stack.imgur.com/kJLLe.png)
[Answer]
# Python
I guess it only works on Windows 7.
```
import win32api, win32con, win32gui
from time import time, sleep
import os
w = { 1:[(358, 263), (358, 262), (358, 261), (359, 261), (359, 262), (359, 264), (359, 266), (359, 270), (359, 282),
     (358, 289), (357, 308), (356, 319), (355, 341), (355, 351), (355, 360), (355, 378), (355, 388), (354, 397),
     (354, 406), (354, 422), (354, 428), (354, 436), (354, 438), (354, 439), (354, 440), (355, 440), (356, 439),
     (357, 439), (358, 438), (360, 438), (362, 437), (369, 437), (372, 437), (381, 437), (386, 437), (391, 437),
     (397, 436), (411, 436), (419, 435), (434, 435), (442, 435), (449, 434), (456, 434), (468, 434), (473, 435),
     (480, 436), (483, 436), (485, 436), (487, 437), (488, 437), (488, 438), (488, 439), (487, 440), (486, 440),
     (485, 440), (484, 440), (483, 439), (483, 437), (481, 431), (481, 427), (481, 420), (481, 413), (483, 396),
     (485, 387), (488, 367), (491, 356), (493, 345), (500, 321), (503, 310), (507, 299), (514, 280), (517, 272),
     (520, 266), (523, 260), (524, 258), (524, 259), (524, 261), (524, 265), (524, 269), (523, 275), (522, 289),
     (521, 297), (518, 315), (516, 324), (515, 334), (513, 345), (509, 368), (507, 382), (502, 411), (500, 426),
     (498, 440), (495, 453), (491, 478), (489, 491), (485, 517), (483, 530), (481, 542), (479, 552), (476, 570),
     (475, 577), (474, 588), (473, 592), (473, 595), (473, 597), (473, 600), (473, 601), (473, 602), (473, 601),
     (474, 599), (475, 597), (476, 594), (478, 587)],
  2:[(632, 305), (634, 306), (636, 309), (639, 314), (641, 319), (645, 330), (647, 337), (649, 353), (649, 362),
     (649, 372), (649, 384), (645, 409), (639, 436), (636, 448), (632, 459), (627, 470), (623, 479), (613, 497),
     (608, 503), (599, 512), (595, 514), (591, 514), (587, 513), (581, 504), (578, 498), (576, 483), (575, 476),
     (575, 469), (579, 454), (582, 447), (591, 436), (595, 432), (600, 430), (605, 429), (617, 432), (624, 437),
     (639, 448), (646, 455), (654, 461), (662, 469), (679, 484), (686, 491), (702, 504), (710, 509), (718, 512),
     (727, 514), (744, 515), (752, 515), (767, 512), (774, 510), (779, 508), (783, 505), (788, 499), (789, 495),
     (789, 486)] }
def d( x1, y1, x2, y2 ):
    win32api.SetCursorPos((x1, y1))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
    win32api.SetCursorPos((x2, y2))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
    sleep(0.01)
def p( l1 ):
    l2 = [""]
    l2.extend(l1)
    l1.append("")
    l3 = zip(l2, l1)
    l3.pop(0)
    l3.pop(-1)
    for n in l3:
        d(n[0][0], n[0][1], n[1][0], n[1][1])
os.startfile("C:\Windows\system32\mspaint.exe")
sleep(0.5)
win32gui.ShowWindow(win32gui.GetForegroundWindow(), win32con.SW_MAXIMIZE)
sleep(0.5)
for n in w:
    p(w[n])
```
The result is opening [Paint](http://en.wikipedia.org/wiki/Paint_%28software%29) and painting 42 as free hand.
![42](https://i.stack.imgur.com/1j0va.png)
[Answer]
## Java (Swing)
This will display a frame drawing **the answer**. It only uses `42` for values.
```
public        class         FourtyTwo{ public
static         void         main(String[]args)
{  new        javax                    .swing.
JFrame        () {{                    setSize
(42 /(        42/42                    +42/42)
*42/ (        42/42                    +42/42)
,42/(42/ 42+42/42)*         42/(42/42+42/42));
}public void paint(         java.awt .Graphics
  g){g.drawPolygon(         new int[]{42,42,42
              + 42+         42,42+
              42+42         ,42+42
              +42 +         42,42+
              42+42         +42,42
              + 42+         42,42+42+42,42+42,
              42+42         },new int[]{42,42+
              42+42         +42,42+42+42+42,42
+42+42+42+42+42,                  42+42+
42+42+42+42,42,42,               42+42+42
,42 +        42+42              ,42}, (42/
42+42        /42)*              (42/  42 +
42/42        + 42/             42 +    42 /
42+42        /42))            ;g.drawPolygon
( new        int[]           {42+42+42+42+42,
42+42        +42 +           42+42      , 42+
42+42        + 42+          42+42        + 42,
42+42        +42 +          42+42        +42 +
42,42+42+42+42+42,         42+42          + 42+
42+42,42+ 42+42+           42+42          +42 +
42+42,42+42+42+42+42+42+42+42,42+42+42+42+42+42,
42+42+42+42+42+42,42+42+42+42+42+42+42+42,42+42+
42+42+42+42+42+42},new int[]{42,42 +42,42+42,42+
42+42,42+42+42,42+42+42+42+42+42,42+42+42+42+42+
42,42+42+42+42+42,42+42+42+42+42,42+42+42+42,42+
42+42+42,42},(42/42+42/42+42/42)*((42/42+42/42)*
(42/42+42/ 42)));};}.setVisible(42*42*42!=42);}}
```
[Answer]
### Mathematica
```
WolframAlpha["meaning of life", {{"Result", 1}, "Content"}]
```
> 
> 42
> 
> 
> 
though I think it's cheating, really, since it's hard-coded. And not very creative, on my part... :)
[Answer]
## Ruby
It is well known what you get [if you multiply six by nine](https://en.wikipedia.org/w/index.php?title=Phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy&oldid=596276371#Answer_to_the_Ultimate_Question_of_Life.2C_the_Universe.2C_and_Everything_.2842.29). This gives one solution:
```
puts (6 * 9).to_s(13)
```
---
## Python
A variant of [Tupper's self-referential formula](https://en.wikipedia.org/wiki/Tupper%27s_self-referential_formula):
```
# Based loosely on http://www.pypedia.com/index.php/Tupper_self_referential_formula
k = 17 * (
    (2**17)**0 * 0b11100000000000000 +
    (2**17)**1 * 0b00100000000000000 +
    (2**17)**2 * 0b00100000000000000 +
    (2**17)**3 * 0b11111000000000000 +
    (2**17)**4 * 0b00100000000000000 +
    (2**17)**5 * 0b00000000000000000 +
    (2**17)**6 * 0b01001000000000000 +
    (2**17)**7 * 0b10011000000000000 +
    (2**17)**8 * 0b10011000000000000 +
    (2**17)**9 * 0b01101000000000000 +
0)
# or if you prefer, k=int('4j6h0e8x4fl0deshova5fsap4gq0glw0lc',36)
def f(x,y):
    return y // 17 // 2**(x * 17 + y % 17) % 2 > 0.5
for y in range(k + 16, k + 11, -1):
    print("".join(" @"[f(x, y)] for x in range(10)))
```
Output:
```
@  @   @@ 
@  @  @  @
@@@@@    @
   @   @@ 
   @  @@@@
```
[Answer]
**Javascript**
```
alert((!![]+ -~[])*(!![]+ -~[])+""+(!![]+ -~[]))
```
[Answer]
# LMGTFY
<http://bit.ly/1ldqJ8w>
Short enough that I had to type this to reach the minimum character count...
[Answer]
Forth:
```
SCR # 1
 0 ( FORTY-TWO @ ES-FORTH )
 1 HEX 0 24 -31 21 -31 31 -31
 2 31 -14 51 11 -11 51 11 -11 23 31
 3 : T SWAP 0 DO DUP EMIT LOOP DROP ;
 4 : K BEGIN DUP WHILE DUP 0< IF CR
 5  ABS THEN 10 /MOD 20 T A0 T
 6  REPEAT DROP ;
 7 K CR
```
That 1 LOAD outputs:
```
   █  ███
 █ █     █
 █ █     █
 ████   █
   █   █
   █  █
   █  ████
```
[Answer]
# C++
```
cout<<"....-"<<" "<<"..---";
```
Morse code ;)
[Answer]
# R
```
sum(as.numeric(factor(unlist(strsplit(gsub(" |[.]","","D. ADAMS"),"")),levels=LETTERS)))
```
Result:
```
42
```
[Answer]
**Java**
```
public class MainProgram {    
    public static void main(String[] args) {
        int[] the      = { 'T', 'h', 'e' };
        int[] most     = { 'M', 'o', 's', 't' };
        int[] creative = { 'C', 'r', 'e', 'a', 't', 'i', 'v', 'e' };
        int[] way      = { 'W', 'a', 'y' };
        int question   = '?';
        double x = -3.18906605923E-2;
        int The      = 0;
        int Most     = 0;
        int Creative = 0;
        int Way      = 0;
        for(int i : the) {
            The += i;
        }
        for(int i : most) {
            Most += i;
        }
        for(int i : creative) {
            Creative += i;
        }
        for(int i : way) {
            Way += i;
        }
        System.out.println((int)((The*x)-(Most*x)-(Creative*x)-(Way*x)-(question*x)));      
    }//SSCE
}//good1
```
Output: 
> 
> 42
> 
> 
> 
[Answer]
SWI-Prolog, anyone?
```
?- X.
```
Output:
```
% ... 1,000,000 ............ 10,000,000 years later
% 
%       >> 42 << (last release gives the question)
```
This is even lazier than the Mathematica-calling-Wolfram-Alpha one, but hey!
[Answer]
# Linux shell
Here’s something I wrote in 1999 and used as my Usenet signature back then.
```
echo "what is the universe"|tr "a-z " 0-7-0-729|sed 's/9.//g;s/-/+/'|bc
```
**Edit:** Ha! This was the 42nd answer.
[Answer]
**PHP version:**
```
 echo strlen("Douglas Adams")+strlen("born on")+array_sum(array(1,1,0,3,1,9,5,2));
 /* array(1,1,0,3,1,9,5,2) => March 11, 1952 */
```
**JavaScript version:**
```
 console.log("Douglas Adams".length + "born on".length + [1,1,0,3,1,9,5,2].reduce(function(previousValue, currentValue, index, array){return previousValue + currentValue;}));
 /* [1,1,0,3,1,9,5,2] => March 11, 1952 */
```
**Output:**
```
 42
```
[Answer]
# dc
```
$ dc <<< "1 8 sc 1 5 lc *++p"
42
```
Trying to multiply `1+8` and `5+1` to get `42`. It looks like that ignorance of operator precedence led to `42`.
---
# Python
```
>>> p = lambda x: x%2!=0 and True<<x
>>> sum(p(i) for i in range(0,6))
```
Output: `42`
---
[Answer]
## Brainf\*\*k
```
- [   --
- -     -
>+<]  >+
  .   --.
```
[Answer]
# C++
```
#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)66<<(char)73<<(char)82;
    cout<<(char)84<<(char)72<<(char)32;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)32<<(char)68<<(char)69;
    cout<<(char)65<<(char)84<<(char)72;
    cout<<(char)32<<(char)32<<'\n';
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)32<<(char)32<<(char)95;
    cout<<(char)95<<(char)95<<(char)32;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)32<<(char)95<<(char)95;
    cout<<(char)95<<(char)95<<(char)95;
    cout<<(char)95<<(char)32<<'\n';
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)32<<(char)47<<(char)32;
    cout<<(char)32<<(char)32<<(char)124;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)124<<(char)32<<(char)32;
    cout<<(char)95<<(char)95<<(char)32;
    cout<<(char)32<<(char)124<<'\n';
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)47<<(char)32<<(char)47;
    cout<<(char)124<<(char)32<<(char)124;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)124<<(char)95<<(char)124;
    cout<<(char)32<<(char)32<<(char)124;
    cout<<(char)32<<(char)124<<'\n';
    cout<<(char)32<<(char)32<<(char)47;
    cout<<(char)32<<(char)47<<(char)32;
    cout<<(char)124<<(char)49<<(char)124;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)32<<(char)32<<(char)47;
    cout<<(char)50<<(char)124<<'\n';
    cout<<(char)32<<(char)47<<(char)32;
    cout<<(char)47<<(char)32<<(char)32;
    cout<<(char)124<<(char)57<<(char)124;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)84<<(char)79<<(char)32;
    cout<<(char)32<<(char)47<<(char)48;
    cout<<(char)47<<(char)32<<'\n';
    cout<<(char)47<<(char)32<<(char)47;
    cout<<(char)95<<(char)95<<(char)95;
    cout<<(char)124<<(char)53<<(char)124;
    cout<<(char)95<<(char)95<<(char)32;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)47<<(char)48<<(char)47;
    cout<<(char)32<<(char)32<<'\n';
    cout<<(char)124<<(char)95<<(char)95;
    cout<<(char)95<<(char)95<<(char)95;
    cout<<(char)124<<(char)50<<(char)124;
    cout<<(char)95<<(char)95<<(char)124;
    cout<<(char)32<<(char)32<<(char)47;
    cout<<(char)49<<(char)47<<(char)32;
    cout<<(char)32<<(char)32<<'\n';
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)124<<(char)32<<(char)124;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)32<<(char)47<<(char)32;
    cout<<(char)47<<(char)32<<(char)32;
    cout<<(char)32<<(char)32<<'\n';
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)124<<(char)32<<(char)124;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)47<<(char)32<<(char)47;
    cout<<(char)95<<(char)95<<(char)95;
    cout<<(char)95<<(char)32<<'\n';
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)32<<(char)32<<(char)32;
    cout<<(char)124<<(char)95<<(char)124;
    cout<<(char)32<<(char)32<<(char)124;
    cout<<(char)95<<(char)95<<(char)95;
    cout<<(char)95<<(char)95<<(char)95;
    cout<<(char)95<<(char)124<<'\n';
    getch();
    return 0;
}  
```
## output
![enter image description here](https://i.stack.imgur.com/r8iXu.png)
[Answer]
# JavaScript
```
window.location = "https://www.google.nl/search?q=the+answer+to+life+the+universe+and+everything";
```
Outputs `42`.
[Answer]
# J
Symmetric one-liner without alphanumeric chars.
```
   _<.>.>_ (=(+^:]) ~=(-*-)=~ ([:^+)=) _<.<.>_
```
Outputs 42.
The main computation is:
> 
>  ceiling( 1 + ( 1 - e ^ 2 ) ^ 2 ) = 42
> 
> 
> 
[Answer]
## JavaScript
The ASCII code for `*`, which for most programmers stands for "everything", is 42.
`+!"The End of the Universe"` evaluates to 0.
```
String.prototype.answer = function() { alert(this.charCodeAt(+!"The End of the Universe")); };
'*'.answer();
```
[Answer]
## PHP
Ask WolframAlpha. Here's some code that uses the WolframAlpha API to retrieve the result of a specific search query:
```
<?php
$searchTerm = "What's the answer to life, universe and everything?";
$url = 'http://api.wolframalpha.com/v2/query?appid=APLTT9-9WG78GYE65&input='.urlencode($searchTerm);
$xml = file_get_contents($url);
$xmlObj = simplexml_load_string($xml);
$plaintext = $xmlObj->xpath('//plaintext')[1];
$answer = preg_replace('/\D/', '', $plaintext);
echo $answer;
```
Output:
```
42
```
### [Working demo](http://codepad.viper-7.com/BaDGtg)
]