text:
Reverse Bit Order of 32-bit Integers
Write the shortest code to reverse the bit order of a 32-bit integer.
Rules:

Input is assumed to be a valid integer or string equivalent if your language doesn't support numerical values (e.g. Windows Batch).
Output must be a valid integer or string equivalent if your language doesn't support numerical values (e.g. Windows Batch).
Standard library only.
It may be a function or a complete program.
Input may be either from stdin or as a function argument.
Output must be either stdout or as a returned value.
If your language has a built-in or standard library function that does this in one step (e.g. rbit in ARM assembly), that cannot be used.

Examples:
Key:

decimal

binary
(reverse)
reversed binary
decimal output

Examples:

-90 (8-bit example for demonstration)

10100110b
(reverse)
01100101b
101

486

00000000000000000000000111100110b
(reverse)
01100111100000000000000000000000b
1736441856

-984802906

11000101010011010001100110100110b
(reverse)
01100101100110001011001010100011b
1704506019

Note: Omissions are free game. If I didn't say it, and it's not one of the standard loopholes, then it's completely allowed.

What is meant by "omissions" in "omissions are free game"?

Anything not explicitly stated in the rules.

Would a 16gb static table be counted as part of the program length?

@HotLicks According to the typical interpretation of program, yes.

language that only supports 8-bit inputs, can we take input as four 8-bit numbers?

@Sparr Yes.

Windows Batch hater detected. :D

@Kroltan Actually, that's where I really learned when goto is or isn't a good thing. There are times when a structured goto is better than anything else, and I get annoyed on occasion on its lack of existence in JavaScript. If you could jump out of a for loop early and skip a section of code (like Python's for else), it could all but eliminate the need for exception handling (which can be a code smell of its own).

@Kroltan On the contrary, it is possible to abuse it. My first programs featuring goto tended to be slightly spaghetti code, especially when I hadn't learned yet about multi-statement if, else, and for statements.

Can I have the checkmark?

x86 assembly, 9 bytes
    xor eax, eax
    inc eax
myloop:
    shr ecx, 1
    adc eax, eax
    jnc short myloop

In byte form: 33 C0 40 D1 E9 13 C0 73 FA, 9 bytes.

That again is exactly as long as my solution if you (a) obey the cdecl calling convention and (b) actually return from the function.

@FUZxxl Somehow, I didn't see your version.  You are completely correct.  I was thinking __fastcall and didn't have the ret.

This does need a ret to be a function (not a snippet), but there's no reason to use an inefficient calling convention like stack args.  Tips for golfing in x86/x64 machine code (So @FUZxxl that part is a missed optimization in your version.  You could take an arg in EDX and return in EAX, and tell GCC for Linux about it with __attribute__((regparm(2)) unsigned rbit(int dummy, unsigned x).  I think __attribute__((ms_abi)) is not fastcall, so IDK how to tell GCC for non-Windows about this version.  Not that it matters, it's asm not C.)

MMIX assembly (28 Bytes)
64 bit numbers
rbit:
    SETH $1,#0102 # load matrix in 16-byte steps
    ORMH $1,#0408
    ORML $1,#1020
    ORL  $1,#4080
    MOR  $0,$1,$0 # multiplication 1
    MOR  $0,$0,$1 # multiplication 2
    POP  1,0      # return

This assembles to:
rbit:
    E0010102 # SETH $1,#0102
    E9010408 # ORMH $1,#0408
    EA011020 # ORML $1,#1020
    EB014080 # ORL  $1,#4080
    DC000100 # MOR  $0,$1,$0
    DC000001 # MOR  $0,$0,$1
    F8010000 # POP  1,0

How does it work?
The MOR instruction performs a matrix multiplication on two 64-bit quantities used as two 8x8 matrices of booleans. A boolean number with digits abcdefghklmnopqr2 is used as a matrix like this:
/ abcd \
| efgh |
| klmn |
\ opqr /

The MOR instruction multiplies the matrices represented by their arguments where multiplication is and and addition is or. It is:
/ 0001 \      / abcd \      / opqr \
| 0010 |  \/  | efgh |  --  | klmn |
| 0100 |  /\  | klmn |  --  | efgh |
\ 1000 /      \ opqr /      \ abcd /

and furthermore:
/ opqr \      / 0001 \      / rqpo \
| klmn |  \/  | 0010 |  --  | nmlk |
| efgh |  /\  | 0100 |  --  | hgfe |
\ abcd /      \ 1000 /      \ dcba /

which is the reverse order of bits of the original number.
32 bit numbers
If you just want the reverse of a 32 bit number instead of a 64 bit number, you can use this modified method:
rbit:
    SETL   $1,#0408 # load first matrix in two steps
    ORML   $1,#0102
    MOR    $1,$1,$0 # apply first matrix
    SLU    $2,$1,32 # compile second matrix
    16ADDU $1,$2,$1
    MOR    $1,$0,$1 # apply second matrix
    POP    1,0      # return

assembled:
rbit:
    E3010408 # SETL   $1,#0408
    EA010102 # ORML   $1,#0102
    DC010001 # MOR    $1,$1,$0
    3B020120 # SLU    $2,$1,32
    2E010201 # 16ADDU $1,$2,$1
    DC010001 # MOR    $1,$0,$1
    F8010000 # POP    1,0

The first matrix multiplication basically works like this:
/ 0000 \      / 0000 \      / 0000 \
| 0000 |  \/  | 0000 |  --  | 0000 |
| 0001 |  /\  | abcd |  --  | efgh |
\ 0010 /      \ efgh /      \ abcd /

the corresponding octabyte is #0000000001020408 which we load in the first two instructions. The second multiplication looks like this:
/ 0000 \      / 0001 \      / 0000 \
| 0000 |  \/  | 0010 |  --  | 0000 |
| efgh |  /\  | 0100 |  --  | hgfe |
\ abcd /      \ 1000 /      \ dcba /

The corresponding octabyte is #0102040810204080 which we create from the first matrix like this:
SLU $2,$1,#32   # $2 = #0102040800000000
16ADDU $1,$2,$1 # $2 = $2 + $1 << 4
                     = $2 + #0000000010204080
                #    = #0102040810204080

The second multiplication is business as usual, the resulting code has the same length (28 bytes).

it's the first time I hear about matrix multiplication instruction on a CPU

@LưuVĩnhPhúc: Not a matrix multiplication, but VAX had an instruction to evaluate a polynomial.

@nneonneo The POLY instruction of the VAX is basically a fused multiply-and-add with a builtin loop. Similar things also exist in modern architectures (like x86), but they usually don't have a builtin loop to evaluate an entire polynomial at once.

80386 assembly (13 12 bytes)
As a function in AT&T syntax using the cdecl calling convention.
    # reverse bits of a 32 bit word
    .text
    .globl rbit
    .type rbit,@function
rbit:
    push $32       # prepare loop counter
    pop %ecx
0:  shrl 4(%esp)   # shift lsb of argument into carry flag
    adc  %eax,%eax # shift carry flag into lsb
    loop 0b        # decrement %ecx and jump until ecx = 0
    ret            # return

This function assembles to the following byte sequence:
6a 20 59 d1 6c 24 04 11 c0 e2 f8 c3

Broken down into instructions:
6a 20       push $32
59          pop %ecx
d1 6c 24 04 shrl 0x4(%esp)
11 c0       adc  %eax,%eax
e2 f8       loop .-6
c3          ret

It works like this: In each of the 32 iterations of the loop, the argument, which is located at 4(%esp), is right shifted by one position. The last bit is implicitly shifted into the carry flag. The adc instruction adds two values and adds the value of the carry flag to the result. If you add a value to itself, i.e. %eax, you effectively left-shift it by one position. This makes adc %eax,%eax a convenient way to left shift %eax by one position while shifting the content of the carry flag into the low-order bit.
I repeat this process 32 times so that the entire content of 4(%esp) is dumped into %eax. I never explicitly initialize %eax as its previous contents are shifted out during the loop.

+1 Thanks for your last sentence, It's obvious now but I missed that.

I'm always happy to see assembly solutions on here :)

As discussed on other answers, use a convenient calling convention as recommended in Tips for golfing in x86/x64 machine code , or a custom convention.  One like x86-64 System V would work well, with the first arg in a register other than EAX or ECX.  That would save 2 bytes in shr %edx

Is there any way to pre-process inputs for crc32 r32, r32 that makes it output the bit-reflection of one input?  I guess probably not, since the final output is the bit-reflection of the remainder polynomial division of a 96-bit temporary by 0x11EDC6F41, so it's probably hard to arrange for the remainder to be something derived easily from an input you want to reflect.

x86 assemply, 10 Bytes
   f9                      stc
   d1 d8            1:     rcr    %eax
   74 05                   je     2f
   d1 d2                   rcl    %edx
   f8                      clc
   eb f7                   jmp    1b
                    2:

This assume input in eax, output in edx. (Also, on output eax is zero and CF and ZF are set, if anyone cares).
Instead of a counter, an additional 1 is pushed in in the beginning as end-of data marker

This has actually the same size as my solution, which is three bytes larger. If you add the ret instruction to return from the function and implement cdecl (i.e. change rcr %eax to rcr 4(%esp) and rcl %edx to rcl %eax), you end up with one extra byte for the ret and another two bytes for the memory reference. Still, a nice solution.

C,   63     52    48
Original version:
int r(int n){int r=0,i=32;for(;i--;r=r<<1|n&1,n>>=1);return r;}

Updated version (with changes suggeted by Allbeert, es1024, and Dennis):
r(n){int r,i=32;for(;i--;r=r*2|n&1,n>>=1);return r;}

Note: Since the second version omits setting r=0, the code is assuming that an int is 32 bits. If this assumption is false, the function will most likely produce an incorrect result, depending on the initial state of r on entry to the function.

Final version (with further changes suggested by Dennis and Alchymist):
r(n,r,i){for(;32-i++;r=r*2|n&1,n>>=1);return r;}

Note: This puts the declaration of the work variables r and i into the parameter list. Parameters are as follows: n is the number to be bit-reversed. r and i are work variables that must be passed as 0.

You could remove the int function type, and also change return r to something like i=r since most C compilers tend to leave the last operation's result in the return register. It worked on gcc and cl for me.

@Allbeert — Ha! Cool. Well, that fails on my compiler (Clang) but I'll definitely take out the int function type, since that's still well-defined in C.

You could shave off another 4 bytes by using r(n){...} instead of r(int n){...}

@es1024 — Ah yes! Thank you; will update.

you can in fact completely drop all type specifiers.

@FUZxxl you can't drop the int in int r=0,i=32; unless you move them out of the function body.

@es1024 Right. But moving them outside will work fine, too.

Also, substitude n/=2 for n>>=1 for one byte and maybe n*2 for n<<1 if the precedence works out.

@FUZxxl — Nope, that only works for unsigned integers. Gotta use >> and << for this, unfortunately.

@Todd huch? That should work just fine.

For signed integers, <<1 is defined as *2 by the C standard, so it has to work. @FUZxxl: >> is implementation-defined behavior. The answer works if it performs a logical shift, while /= would be equivalent to an arithmetic shift.

r(n,s,i){for(i=32;i--;s=s*2|n&1,n>>=1);return s;} is a little shorter. Technically, omitting s=0 is undefined behavior (because of signed integer overflow), but since it's code golf...

Ah yes! Thank you. Brain fart on my part. Of course *2 works just as well as <<1. Silly me, I wasn't thinking beyond the right shift.

@Dennis It doesn't look like the answer depends on signed vs. unsigned shift behavior. The answer right-shifts n 32 times and never evaluates any of the sign-bits shifted through.

@FUZxxl: Shouldn't comment when I'm tired... Arithmetic shift and division are not equivalent; the latter rounds towards zero, while the first rounds towards negative infinity. -1 >> 1 is -1 for AS and 2**31 - 1 for LS, while -1 / 2 is 0.

@Todd: Any reason you didn't define r and i as arguments? Would save three more bytes...

@Dennis Actually, right shifting negative values is implementation defined in C and -1 >> 1 may very well yield 0, for instance on a sign-and-magnitude architecture.

@FUZxxl — Good point about the sign of the result of >> being implementation-defined. Fortunately, in this case, it's only ever looking at the LSB after a right shift, so whatever goes into the MSB is ignored. :)

@Dennis — I always thought of that as sort of cheating, since it puts an ugly burden on the caller. But in looking at the rules, it doesn't seem to be disallowed. Also, in this particular case, it allows me to ensure that r is initialized to zero. So... thanks, I added that change and now it's down to 49 bytes. :)

Just call it as r(n). Technically undefined behavior, but should work just fine.

@Dennis — LOL, that's awesome...hahaha :)

If we allow passing in 0 initialised values then you can replace i=32;i--; with ;32-i++;

@Alchymist — Mind blown. Suggestion applied! — thanks!

Julia 0.2, 33 bytes
f(n)=parseint(reverse(bits(n)),2)

Does what it looks like.
bits gives you the bit representation (respecting two's complement). parseint doesn't care about two's complement, but returns a 32 bit integer, so the two's complement is simply handled by overflow.
According to the changelogs, overflow detection was added to parseint in Julia 0.3, so this might not work any more.

This is production code, not golfed code! xD I guess Julia's just great.

JavaScript (E6) 37 39 40 50
Function, number input and returning reversed number. Most basic algorithm, probably can be golfed more with some smart trick.
Edit Recursion instead of loop
Edit 2 Following @bebe suggestion k*2 instead of k<<1
Edit 3 Something I had missed at all: it's a full 32 bit loop, no need to initialize k. Thanks @FUZxxl
R=(v,b=32,k)=>b?R(v>>1,b-1,k*2|v&1):k

It was
R=v=>{for(k=b=0;b++<32;)k+=k+(v&1),v>>=1;return k}

Test In FireFox console, test using numbers in OP and some more random 16 and 32 bit numbers
Bin=x=>('0'.repeat(32)+(x<0?-x-1:x).toString(2)).slice(-32).replace(/./g,d=>x>0?d:1-d),
Dec=x=>(' '.repeat(11)+x).slice(-11),
R16=_=>Math.random()*65536|0,
R32=_=>(Math.random()*65536<<16)|R16(),
[-90,486,-984802906,R16(),R16(),R16(),R32(),R32(),R32(),R32()]
 .forEach(n=> console.log(Dec(n)+' '+Bin(n)+' '+Dec(R(n))+' '+Bin(R(n))))

Example of test output
        -90 11111111111111111111111110100110  1711276031 01100101111111111111111111111111
        486 00000000000000000000000111100110  1736441856 01100111100000000000000000000000
 -984802906 11000101010011010001100110100110  1704506019 01100101100110001011001010100011
      45877 00000000000000001011001100110101 -1395851264 10101100110011010000000000000000
      39710 00000000000000001001101100011110  2027487232 01111000110110010000000000000000
      56875 00000000000000001101111000101011  -730136576 11010100011110110000000000000000
-1617287331 10011111100110100010011101011101 -1159439879 10111010111001000101100111111001
-1046352169 11000001101000011110111011010111  -344488573 11101011011101111000010110000011
 1405005770 01010011101111101010111111001010  1408597450 01010011111101010111110111001010
  -35860252 11111101110111001101000011100100   655047615 00100111000010110011101110111111

b=k=0,R=v=>b++<32?R(v>>1,k+=k+(v&1)):k for single use
and R=(v,b=0,k=0)=>b<32?R(v>>1,b+1,k+k+(v&1)):k is reusable

@bebe :( I was revising my answer using recursion and lost all to read your comment...

you're at 38 bytes if k<<1 becomes k*2 and v>>1 becomes v/2. it worked for 486. i dont know about other test cases

@bebe v/2 will not work for negative numbers. 486/512 == 0.9... and 486>>9 == 0, trunc it's the same. But -90/128 == -0.7... and -90>>7 ==-1

Python 2, 50
print int("{:032b}".format(input()%2**32)[::-1],2)

Broadly the same as my Pyth solution. Take the input mod 2**32, convert to 32-bit padded binary, reverse, convert binary sting back to decimal and print.

CJam, 15 bytes
li4H#+2bW%32<2b

Try it online.
"Free game" joker used: The output will always be an unsigned integer.
Test cases
$ cjam reverse32.cjam <<< 486; echo
1736441856
$ cjam reverse32.cjam <<< -984802906; echo
1704506019

How it works
li   " Read from STDIN and cast to integer. ";
4H#+ " Add 4 ** 17 to avoid special cases. ";
2b   " Convert into array of digits in base 2. ";
W%   " Reverse the order. ";
32<  " Discard the 33th and all following digits. ";
2b   " Convert the array of digits into an integer. ";

Dyalog APL, 10 bytes
2⊥⌽⎕⊤⍨32/2

2⊥ from-base-2 of
⌽ the reversed
⎕ numeric input
⊤⍨ in the number system consisting of
32/2 32 bits
TryAPL online!

J (17 15 13 bytes)
_32#.@|.@{.#:

Here is an explicit definition to explain what it does:
3 : '#. |. _32 {. #: y'

#: y represents y as a base 2 number using as many places as necessary.
x {. y takes |x (magnitude of x) items from y, from the front if x is positive, from the back if x is negative. If we take more items than present, the result is padded with zeroes. _32 {. #: y effectively pads #: y to 32 bits.
|. y flips y, i.  reverses the order of items in y.
#. y  interprets  y as a base-2 number.

Pyth, 33 32 22
v_%"%032db0"vsc%Q^2 32

Explanation:
                 Q             Evaluated input.
                %Q^2 32        Q mod 2^32. Same 32 bit binary representation as Q.
             vsc%Q^2 32        Convert to binary string, then that to decimal int.
   %"%032db0"vsc%Q^2 32        Pad above number to 32 bits, and append b0.
  _%"%032db0"vsc%Q^2 32        Reverse it.
 v_%"%032db0"vsc%Q^2 32        Eval and print. Due to leading "0b", eval as binary.

Golfs:
33 -> 32: Moved add to before reversing to save an end-quote.
32 -> 22: Used Q mod 2^32 instead of complicated machinery. Combined both strings into one.
Test cases:
$ cat rev_bits
v_%"%032db0"vsc%Q^2 32

$ ./pyth.py rev_bits <<< -984802906
1704506019

$ ./pyth.py rev_bits <<< 486
1736441856

$ ./pyth.py rev_bits <<< 0
0

Does it work with result as a big 32 numbers having leftmost bit at 1? In this case it should output a negative integer.

@edc65 I'm outputting a 32 bit unsigned integer.

GNU dc, 27 bytes
0?[2~rssr2*+dlsz34>m]dsmx+p

Output:
$ dc revbits.dc <<< 15
4026531840
$ dc revbits.dc <<< 255
4278190080
$ dc revbits.dc <<< 65535
4294901760
$ dc revbits.dc <<< 4294901760
65535
$ dc revbits.dc <<< 4278190080
255
$ dc revbits.dc <<< 4026531840
15
$

Bash+coreutils, 45 bytes
n=`dc -e2do32^n$1p`
dc -e2i`rev<<<${n: -32}`p

Output:
$ ./revbits.sh 15
4026531840
$ ./revbits.sh 255
4278190080
$ ./revbits.sh 65535
4294901760
$ ./revbits.sh 4294901760
65535
$ ./revbits.sh 4278190080
255
$ ./revbits.sh 4026531840
15
$

C function, 89 bytes
Same idea as https://codegolf.stackexchange.com/a/36289/11259 - using the Stanford bit twiddling hacks.  Not going to win the golfing, but interesting nonetheless:
// 89 byte function:
i;r(v){for(i=1;i<32;i*=2)v=v>>i&(1L<<32)/((1<<i)+1)|(v&(1L<<32)/((1<<i)+1))<<i;return v;}

// Test program:
#include <stdio.h>

int main (int argc, char **argv)
{
    printf("r(0x0000000f) = 0x%08x\n", r(0x0000000f));
    printf("r(0x000000ff) = 0x%08x\n", r(0x000000ff));
    printf("r(0x0000ffff) = 0x%08x\n", r(0x0000ffff));
    printf("r(0xffffffff) = 0x%08x\n", r(0xffffffff));
    printf("r(0x0f0f0f0f) = 0x%08x\n", r(0x0f0f0f0f));
    printf("r(0xf0f0f0f0) = 0x%08x\n", r(0xf0f0f0f0));
}

Output:
$ ./revbits
r(0x0000000f) = 0xf0000000
r(0x000000ff) = 0xff000000
r(0x0000ffff) = 0xffff0000
r(0xffffffff) = 0xffffffff
r(0x0f0f0f0f) = 0xf0f0f0f0
r(0xf0f0f0f0) = 0x0f0f0f0f
$

Python - 89
def r(n):
 if n<0:n=~n^0xFFFFFFFF
 print int(['','-'][n%2]+'{:032b}'.format(n)[::-1],2)

Python represents negative binary numbers as simply -0b{positive_number}. So to deal with this, complement negative numbers and then XOR with all 1's.
After that, create the string representation of the integer based on the format {:032b} which provides the 32bit representation of the number. Finally, reverse the string and turn it back into an integer.
EDIT
Thanks to @Martin Büttner for pointing out a two's complement issue. If n ends in a 1 then by two's complement the reversed version would be negative.
Luckily, as explained above, Python likes negative binary numbers in a pretty simple way. Also luckily, Python's int function allows optional sign characters in its first argument.
So now, add a minus sign if n is odd to satisfy two's complement.

@MartinBüttner Thanks. I missed that possibility at first. The new code handles two's complement better.

You can golf that a bit more: ['','-'][n%2] is '-'*(n%2).

Java function, 64 chars.
 int r(int n){int r=0,i=32;for(;i-->0;n>>=1)r=r<<1|n&1;return r;}

Should also work in C.

PHP, 46 Bytes
Online Versions

for(;$i<32;)$t.=$argn>>$i++&1;echo bindec($t);

or
<?=bindec(strrev(sprintf("%064b",$argn<<32)));

The substr is unnecessary (-12 bytes). You should mention how to run them.

@Titus have you tried the testcase -984802906 ?

Your second version can be improved to match the first: <?=bindec(strrev(sprintf("%064b",$argn<<32)));

@Christoph very nice improvement Thank You

C# 142
using System;using System.Linq;int f(int n){return Convert.ToInt32(new string(Convert.ToString(n,2).PadLeft(32,'0').Reverse().ToArray()),2);}

Expanded
int f(int n)
{
    return Convert.ToInt32(
        new string(
            Convert.ToString(n, 2)
            .PadLeft(32, '0')
            .Reverse()
            .ToArray()), 2);
}

Python - 37
Similar to @isaacg's solution.
f=lambda n:int(bin(n%2**32)[:1:-1],2)

C++, 160
This isn't the shortest one, however it uses only 24 operations.
Taken from Hacker's Delight book.
Golfed:
typedef unsigned U;U R(U&x){U a=-1u/3,b=-1u/5,c=-1u/17,d=65280;x=(x&a)*2|(x/2)&a;x=(x&b)*4|(x/4)&b;x=(x&c)<<4|(x>>4)&c;x=(x<<24)|((x&d)<<8)|((x>>8)&d)|(x>>24);}

Ungolfed:
unsigned R(unsigned x) {
    x = (x & 0x55555555) <<  1 | (x >>  1) & 0x55555555;
    x = (x & 0x33333333) <<  2 | (x >>  2) & 0x33333333;
    x = (x & 0x0F0F0F0F) <<  4 | (x >>  4) & 0x0F0F0F0F;
    x = (x << 24) | ((x & 0xFF00) << 8) | ((x >> 8) & 0xFF00) | (x >> 24);
    return x;
}

This is a code golf question. Please try to reduce the number of characters in your solution, not the number of operations.

C# 81 74
int R(int V){int l,r=l=0,i=1;for(;i>0;i*=2)r|=i*(1&V>>(31-l++));return r;}

Bit operations which most likely can be done shorter in all programming languages.
Basically, loop through all powers of 2 up to integer maximum+1(Which turns into a power of two) and since (2,147,483,647+1)=0 I can loop to 0. Bit shift Left to right to move the bit into the first position. Last bit at place 32 goes 31 steps to the right, second last goes 30 etc. So by using AND operator with 1 i will know if it is 1 or 0. If it is 1 I will add the current i value to the result and return it.
int R(int V)
{
    int l,r=l=0,i=1;
    for(;i>0;i*=2)
        r|=i*(1&(V>>(31-l++)));
    return r;
 }

Small things, but you can initialize i when you declare it, and save a byte by removing i++ from the for loop, and instead of comparing the result of 1&... with 0 you can remove the if statement altogether and multiply i by the result giving r|=i*(1&(V>>(31-l++))); inside the loop

Clever! I had a feeling I was missing something. Thanks!

JS 115
Well that doesn't look good at all :D
n=+prompt();alert(eval('0b'+(Array(33).join(0)+(n<0?n>>>0:n).toString(2)).slice(-32).split('').reverse().join('')))

@Florian F's method in JS is 53 bytes long:
for(n=+prompt(r=0),i=32;i--;n>>=1)r=r<<1|n&1;alert(r)

The it may be a function rule means you don't need the alert or prompt

Haskell, 145  - no bitwise operations
Bit-twiddling strikes me as the antithesis of Haskell, so I've avoided any use of bitwise operators.  The resulting program is certainly not the shortest contestant, but I thought the use of math instead of bit-twiddling was interesting at least.
import Data.Tuple
import Data.List
f m=foldl1((+).(*2))$take 32$(unfoldr(\n->if n==0 then Nothing else Just$swap$divMod n 2)$mod m$2^32)++[0,0..]

Explanation
f m=foldl1((+).(*2))$take 32$(unfoldr(\n->if n==0 then Nothing else Just$swap$divMod n 2)$mod m$2^32)++[0,0..]
    |------5-------|---4----|--------------------------2---------------------------------|----1-----|---3----|

uses modulo to bring the result into 32-bit range
constructs a list of 0s and 1s, least significant bit first by repeatedly dividing by 2 and taking the remainder
concatenates an infinite list of 0s to the end of this list
grabs the first 32 elements of the list (These last two were needed to ensure the list is actually 32 bits long.)
converts a list of 0 and 1 into an integer assuming the most significant bit is first (repeated double and add).

I'm not quite sure what constitutes "the standard library" in Haskell so I assumed Data.Tuple and Data.List were OK (they are pretty standard).
Also, the output is an unsigned 32-bit integer since changing that would cost me bytes: I'm arguing this under "omissions are free game".

Standard library: what ships with the language. This includes system headers for C, the 4000+ classes and methods in Java's (most are irrelevant).

PHP, 46 41 bytes
try them online
while($i<32)$r=$r*2|$argn>>$i++&1;echo$r;

bitwise ... more or less. Run as pipe with php -nR '<code>'.
PHP, 46 bytes
while($i<32)$r|=($argn>>$i&1)<<31-$i++;echo$r;

a pure bitwise solution; run as pipe with -nR.
PHP, 47 59 bytes
<?=bindec(str_pad(strrev(substr(decbin($argn),-32)),32,0));

another built-in approach; save to file and run as pipe with -F.

ARM Thumb machine code, 10 bytes
00000000: 01 20 49 08 40 41 fc d3 70 47            . I.@A..pG

As per request, this does not use the rbit instruction.
    .syntax unified
    .arch armv7-a
    .thumb
    .globl rbit
    .thumb_func
    // input: r1
    // output: r0
rbit:
    // sentinel bit
    movs    r0, #1
.Lloop:
    // shift the lowest bit into the carry flag
    lsrs    r1, #1
    // shift in with adc, put highest bit in carry flag
    adcs    r0, r0
    // when the carry is set we flipped all 32 bits
    bcc     .Lloop
    // return
    bx      lr

ARM Thumb machine code (with builtins), 6 bytes
00000000: 90 fa a0 f0 70 47                   ....pG

This is literally the rbit instruction that was explicitly disallowed but I am providing for reference
    .syntax unified
    .arch armv7-a
    .thumb
    .globl rbit_cheater
    .thumb_func
    // input: r0
    // output: r0
rbit_cheater:
    // Trivialize the challenge.
    rbit   r0, r0
    // Return
    bx     lr

R, 45
f=function(x)packBits(intToBits(x)[32:1],"i")

Examples:
f(486)
# [1] 1736441856
f(-984802906)
# [1] 1704506019

Always just shy of the Python answers. That damn function keyword.

Ruby, 43 41 bytes
def r(n)(0..31).inject(0){|a,b|a*2+n[b]}end
In Ruby, using the bracket index notation (foo[i]) returns the bit at the nth place.
--Edit--
Refactoring the inject functionality shaves a couple bytes
def r(n)z=0;32.times{|i|z=z*2+n[i]};z;end

Perl5: 46
sub r{for(0..31){$a=$a*2|$_[0]&1;$_[0]>>=1}$a}

Nothing fancy. It shifts output left, copy lsb before shifting source right.

Clojure, 202 156 142
#(read-string (let [s (clojure.pprint/cl-format nil "~2r" %)](apply str (reverse (apply str (concat (repeat (- 32 (count s)) "0") s "r2"))))))

Perl - 60
$_=unpack"N",pack"B*",scalar reverse unpack"B32",pack"N",$_

+1 for the p flag (let me know if I'm counting this wrong).
Run with:
echo 486 | perl -pe'$_=unpack"N",pack"B32",scalar reverse unpack"B32",pack"N",$_'

C++ 69
int r(int n){int e=0,i=0;for(;i<32;i++)e|=((n>>i)&1)<<31-i;return e;}

@bebe what are these e;i;? Declarations without type are not a valid C++. For variables it's not even valid C.

@Ruslan i didn't recognize '++' in the title, sorry. (i wouldn't agree with your second statement)

int r(int n){int e=0,i=0;for(;i<32;)e=e*2|1&n>>i++;return e;} 61 bytes :)

Perl (37+1)
basically a port of the C solution by Todd Lehman
perl -E '$t=<>;map$r=2*$r|1&$t>>$_,0..31;say$r'

JavaScript (ES6), 32 bytes
(n,m=32)=>(--m&&f(n,m)*2)|n>>m&1

Wrote this while trying to solve Bit-Reversal Permutations - it didn't help there, but it works fine here!

PASM (P8X32A assembly language), 4 bytes, 1 instruction
REV $1ef, #0

Assembles to:
00 DE FF 3C

Explanation:
Reverses the low 32-0 bits (e.g. all of them) in place in location 0x1ef.
Quite why this instruction exists is a mystery to me.  Probably to make life extremely awkward for emulator authors. :)

05AB1E, 9 bytes
b32jð0:RC

Try it online!
Uses unsigned integers.
b   convert input to binary
32j pad to length 32
ð0: replace spaces by zeroes
R   reverse
C   convert to decimal

I don't know if that counts as "omissions", but if input and output are allowed in binary, then the one-byter R will do the work.

First of all, OP explicitly stated that I/O must be in decimal, and even if this wasn't the case R still breaks the rule that built-ins aren't allowed.

Ok, then the single "R" isn't allowed, but the 9-byte answer is.

Yes, that is correct.

C, 40 38 bytes
using a recursive function and multiplication by 1u to cast from int to unsigned
R(I){return I?I<<31|R(I*1u/2)*1u/2:0;}

edit:
replaced right shift with division by 2
Try it online!

Factor, 33 bytes
[ 32 <bits> reverse bits>number ]

Try it online!
Explanation:

32 <bits> represent an integer as a virtual sequence of 32 bits (booleans)
reverse reverse the sequence
bits>number convert a sequence of booleans to an integer


text:
Input a number and return day of week
Not restricted to any one programming language.
What I'm saying is you pass 1 to it and it returns Monday, 7 corresponds with sunday and so on.
I've managed a 146 byte statement in Java to do the same.
return (n<1?"invalid":(n<2?"monday":(n<3?"tuesday":(n<4?"wednesday":(n<5?"thursday":(n<6?"friday":(n<7?"saturday":(n<8?"sunday":"invalid"))))))));

Your program should:

output full words (STDOUT)
not crash if the input is less than 1 or greater than 7

updated tags. my bad! i've kept it as a popularity contest, as open-platform code-golf ends up being one language versus the other more than one logic versus the other. Most upvotes (thus most recognition and appreciation for logic) wins.

have I been downvoted as a sign of disappointment in my question, or my code?

my bad, again. first question, sorry.

I can't know what other people are downvoting for, but I would expect people to dislike the use of "popularity contest" on a question that is purely a golf question. Generally popularity contest is used for questions that don't have an objective way of deciding a winner.

will keep in mind. I wasn't aware of the setting guidelines.

This question can't agree with itself on what it wants people to write. A statement which finds input in a variable and returns it or a program which writes to stdout? (It's also a bizarre use of [tag:popularity-contest] which, if it catches on, might do a lot to help those who want to kill the tag completely).

You'll learn what works and what makes a good question by asking questions just like you are, and getting feedback. I personally thought this question was too simple to make an interesting challenge, but you have 3 answers already in just half an hour, which shows that it's hard to guess what makes a good challenge until you ask it. With the new reputation you gain from this question you'll soon be able to use the sandbox to get feedback on ideas before you post them.

Note that questions are language agnostic by default - you don't need to specify that it's not restricted to one programming language.

@peter-taylor that was not my intention.

Why answering yourself in your question? That's a pity for those who want to search a clever solution by themselves. You can add an answer of your own instead!

@Blackhole it's a reference implementation. Much larger than a winning golf entry, so it's not really preventing anyone from being clever. It is, however, providing precise output examples for all input cases.

The question says you should output to stdout, but the accepted answer doesn't do so and even assumes the existence of a variable. Also, do we have to output invalid if the input is invalid? The question doesn't state that but the example suggests so.

Ruby, 69 or 38 bytes
Here is a simple way to improve your code (written in Ruby but it works similarly in Java):
n>0&&n<8?%w{Mon Tues Wednes Thurs Fri Satur Sun}[n-1]+"day":"Invalid"

Combine the two invalid checks into one.
Put all the days in an array and use n as an index.
Factor out the common day.

You can make it even shorter if you import the names of the days of the week from a library, like Ruby's:
n>0&&n<8?Date::DAYNAMES[n%7]:"Invalid"

Note that now I don't decrement n but instead take it modulo 7 to map 7 to 0. This is because DAYNAMES starts with Sunday.

Gah, I was just about to put a Lua version of this same thing (except it was going to be about 100 characters longer)...

damn, I wasn't thinking on the lines of arrays at all. I had gotten so caught up in ternary, that I hadn't realized I could merge the two. amazing!

Can you do n>0&n<8 (removing the second &) in Ruby?
I know that works in Java.

@bmarks It looks like you can't due it due to precedence, at least before Ruby 2.0 (I don't have a Ruby 2.x interpreter here right now).

21 in Rebmu ... :-)

Bash: 47 bytes
Still no bash entry? I'm disappointed ...
case $1 in
    [1-7]) date -d "14-08-1$1" +%A
esac

It uses the days of the current week and simply substitutes the last digit (11-17 August 2014 -- 11 is Monday, 12 is Tuesday, etc.).

Wow, what a clever solution! Hard coding a date for this is brilliant!. Is there no way for the date format to accept just '8' as the month? And then you can find a month/year pair where the first is a monday.

Thanks! date -d $1sept +%A works as well (though only this year; reduces bytes to 6*9). GNU date is really flexible in that matter so there should be additional possibilities.

If you post this as an answer for date rather than Bash, it would be a mere 14-08-1$1 – 9 bytes!

It's 46 bytes, don't count the trailing newline;

Well, more than 2 times shorter version :): http://codegolf.stackexchange.com/a/36424/11887 .

Javascript, 95 88 bytes
x=prompt();alert("Invalid 0Mon0Tue0Wednes0Thurs0Fri0Satur0Sun".split(0)[x&~7?0:x]+"day")

7 in binary is 0111, meaning that you can shave off a few characters with a bitwise operation instead of x>0&&x<8.
Edit: Removed the s array with the help of edc65.

that's a neat method!

Neat method indeed. 1) I count 95 bytes, not 97. 2) You don't need ad s variable and can do 88:x=prompt();alert("Invalid 0Mon0Tue0Wednes0Thurs0Fri0Satur0Sun".split(0)[x&~7?0:x]+"day")

Ah, that's clever! I'll update my post now.

Marbelous 192 191 185 181
}0
=1=2=3=4=5=6=7--
&1&2&3&4&5&6&7{0
&8////////////
4D6F6E547565735765646E65735468757273467269536174757253756E646179
&1&1&1&2&2&2&2&3&3&3&3&3&3&4&4&4&4&4&5&5&5&6&6&6&6&6&7&7&7&8&8&8

Non-zero exit code if the input is invalid
Usage:
# marbelous.py -r day-of-week.mbl 2
Tuesday

C# - 26 Bytes
Expects the day to be stored inside n.
Does not crash, as expected.
Powered by LINQPad™
((DayOfWeek)(n%7)).Dump();

 Special thanks to bmarks and  Stephan Schinkel for byte saving and rule bending, respectively

Can you remove the second & in the conditional? I don't think short circuit evaluation here is necessary.

@bmarks You're correct, thanks

The Question does not mentione to return "Invalid" it just states the program should not crash. So you could write return ((DayOfWeek)(i%7)).ToString(); (37 chars)

@StephanSchinkel Yeah, I guess you're right

Lua - 57 bytes
print(n>0 and n<8 and os.date("%A",9e4*(n+3))or"Invalid")

Lua has os.date() in it's standard library, and it has formatting. So you can pass a time (in this case "9e4*(n+3)") and ask to return the "%A" format, which is the names of the days of the week.
Also, very useful in Lua is "a and b or c". If a is true (in the code a is "n>0 and n<8") it returns b, if a is false (or nil) it returns c.

Can you provide an explanation?

The OP specifically asked for error handling, although it was pretty vague. Next time, ask for clarification before posting an incomplete answer.

I don't think the space after %A is necessary

@KyleKanos Right you are. Thanks!

Bash - 21 19
Assuming the input is in variable D:
date +%A -d$D"Jan1"

HTML + PHP - 26
Let $d be an input text
<?=date('l',86400*(3+$d));

Timestamp 86400*3 is the first Sunday from the start of UNIX world.
You can test it by executing:
<?php $d=3; ?>
<?=date('l',86400*(3+$d));

C#, 95 bytes
In C# you can do something like this:
return(i>7||i<0)?"invalid":new[]{"mon","tues","wednes","thurs","fri","satur","sun"}[i-1]+"day";

There is an error in the bounds checking, you need to be checking that i<1, and you can save 2 bytes by using | rather than || (not short-circuiting) and removing the brackets around the condition. It's also shorter to create and split a string thus " mon tues wednes thurs fri satur sun".Split()[i] than to create an array of string of this size (note the space at the start of the string, which saves subtracting 1 from i)

Javascript 93 :(
q=prompt();alert(q<8&&q>0?'0mon0tues0wednes0thurs0fri0satur0sun'.split(0)[q]+'day':'invalid')

why exactly have you used q&&q<8 ?

q&&qq<8 checks if q is between 1 and 7

What if q is -5?

:( but thats an extra 2 bytes for >0. Fixed using ipi's bit trick, also saves 2 bytes

Does it work with q == 0?

@edc65 fixed :(

T-SQL 36
SELECT DATENAME(w,@+6)WHERE(6+@)/7=1

Assumes the variable is stored in @. If it is an invalid input (@>7 or @<1), then it doesn't select anything.
Edit: Apparently a date can be a number. Removed 5 characters with that.
Edit 2: Based on the first edit. Since it's an int, I don't have to use DATEADD(); I can use normal addition instead.

Extended BrainFuck: 104
{a))<(->>}+>,49-(-(-(-(-(-((-)<->>|"sun")<(->>|"satur"&a|"fri"&a|"thurs"&a|"wednes"&a|"tues"&a|"mon")|"day"

Ungolfed (Idiomatic)
{main
  :flag +
  :input

  $input &read_number -
  (-
   (-
    (-
     (-
      (-
       (        $input &reset  ; 7-9
                $flag  &reset
                |"sun" &reset )

        $flag ( &reset         ; 6
                |"satur" &reset  ))

       $flag (  &reset         ; 5
                |"fri" &reset    ))

      $flag (   &reset         ; 4
                |"thurs" &reset  ))

     $flag (    &reset         ; 3
                |"wednes" &reset ))

    $flag (     &reset         ; 2
                |"tues" &reset   ))

   $flag (      &reset         ; 1
                |"mon" &reset    )

   |"day"
}
{reset (-)}
{read_number , 48- }

;; call main
&main

Mathematica 19 16 bytes
DayName@{1,1,#}&

As Dr. Rebmu noted, January 1, 1 A.D. is a good place to start.  It (presumably) fell on a Monday.
    DayName@{2014, 9, #} &[1]

Monday

Why September of 2014 and not January 1st year 1 AD?

The answer is: I failed to think of it.  But I will incorporate your suggestion.

Python (84)
lambda a:'imtwtfssnouehrauvneduitnadsnrdudladesaraiyasdydyd yda a    ay y    y'[a if 0<a<8 else 0::8]

I suppose it's an interesting sollution. It takes an idea from another answere I read somewhere (can't find it, I do know it was on this site, so if anyone knows feel free to tell me.)
The string was generated with the following J program:
,|:>'invalid';'monday';'tuesday';'wednesday';'thursday';'friday';'saturday';'sunday'

Taking some subtle hints from this answer:
lambda a:' mtwtfssouehrauneduitn snr u   es r   s'[a::7]+'day'if 0<a<8 else'invalid'

Befunge-93 (206 208)
This one was fun to write. I'm sure it can be done in a better way, but… it works! =)
Can be tried out here.
Would've been even shorter if the # would jump over entire strings rather than just the individual cell.
&1-    v
vv"Mon"># :# !_
> 1-    v
vv"Tues"># :# !_
> 1-      v
vv"Wednes"># :# !_
> 1-     v
vv"Thurs"># :# !_
> 1-   v
vv"Fri"># :# !_
> 1-     v
vv"Satur"># :# !_
> 1-   v
vv"Sun"># :# !_
>>:#,_"yad",,,@

The basic idea behind it: Get the number and keep decrementing it. Everytime we decrement it, the cursor moves to the right, wraps around and is sent one level lower. Once we hit zero, move to the left instead and push the (first part of the) day name. From then on, the cursor will move straight to the bottom where the string is printed and "day" is appended.
You can see how it works by using the "Step" feature in the link to the online interpreter.
Edit: I managed to shave two bytes off by doing >:#,_ instead of >,,,,,,, which is pretter as well.

Clojure - 99 chars
Plain and simple, despite my best (newbie) attempts:
(defn f[x](get{1"monday"2"tuesday"3"wednesday"4"thursday"5"friday"6"saturday"7"sunday"}x"invalid"))

Perl, 54
From STDIN to STDOUT, no date functions, no crash.
print((a,Mon,Tues,Wednes,Thurs,Fri,Satur,Sun)[<>].day)

JS: 58
Assuming n is already stored as a variable.
"0Mon0Tues0Wednes0Thurs0Fri0Satur0Sun".split(0)[n%8]+"day"

As an ES6 function (same assumptions): 67
let d=n=>"0Mon0Tues0Wednes0Thurs0Fri0Satur0Sun".split(0)[n%8]+"day"

This will just print "day" for 0 and loops around for n > 7

"Tueday"? Also, your description is inaccurate, it returns day for 8 and starts again from Monday at 9.

@nyuszika7h Thanks for the catch.

Haskell - 62
Wraps around; 0 is Sunday, 8 is Monday, and so on.
words"Mon Tues Wednes Thurs Fri Satur Sun"!!(mod(n-1)7)++"day"

If printing to stdout is required (68 bytes, output is in double quotes):
print$words"Mon Tues Wednes Thurs Fri Satur Sun"!!(mod(n-1)7)++"day"

MATLAB : 33
datestr(3:9,'dddd');ans(1:7==n,:)

MATLAB : 71
{'mon';'tues';'wednes';'thurs';'fri';'satur';'sun'};[ans{1:7==2} 'day']

Haskell : 75
g n=((++"day").last.take(abs n).words)"mon tues wednes thurs fri satur sun"

Haskell : 97
f n=if elem n[1..7]then["mon","tues","wednes","thurs","fri","satur","sun"]!!n++"day"else"invalid"

Python 3.4.1 : 81
'invalid mon tues wednes thurs fri satur sun'.split(' ')[n*(n in range(8))]+'day'

You probably should post these as separate answers.

In Python: (0<n<8) is shorter then (n in range(8)). split() also split string

PHP (56 bytes)
$d=1;echo$d>0&&$d<8?date('D',255600+$d*86400):'Invalid';

LiveScript - 49
Returns undefinedday if the input is invalid. ;)
<[Mon Tues Wednes Thurs Fri Satur Sun]>[n-1]+\day

If printing to stdout is required (60 bytes):
console.log<[Mon Tues Wednes Thurs Fri Satur Sun]>[n-1]+\day

Rebmu: 21 characters
pcSYSTEM/locale/daysA

To run:
>> rebmu/args {pcSYSTEM/locale/daysA} 1
== "Monday"

Invalid numbers will return "none".
>> rebmu/args {pcSYSTEM/locale/daysA} 8
== none

>> rebmu/args {pcSYSTEM/locale/daysA} 0
== none

For those unfamiliar with Rebmu, it uses case transitions to remove the need for spacing--within the limits of what's legally parseable.  Rather than using a InitialCapsToBreak it uses CASEtransitionsTObreak, because that allows a different meaning to be ascribed to an initial run of capitals from if the initial initial run is lowercase.
So it is equivalent to the Rebol program pick system/locale/days a.  (Rebmu by convention names its script parameter as "a").
Saves one character over system/locale/days/(a) :-)

Lua 134 119 115 100 98
q={"mon","tues","wednes","thurs","fri","satur","sun"}print(n<8 and n>0 and q[n].."day"or"invalid")

Basically the same thought MartinButtner had, except about 4.5 4.1 1.7 1.4 times longer. Does assume n is stored as a variable elsewhere.

In fairness, you don't need any of that I/O here.

@MartinBüttner: I think it's longer if I use a function

Just expect n to be stored in a variable, as in the OP's snippet.

yeah, I wasn't expecting any I/O on your side.

Perl, 60 bytes
Something like this:
$x&&qw{Mon Tues Wednes Thurs Fri Satur Sun}[$x-1]."day"||die

If want to return a message instead and you're concerned about negative indexes you can use this one instead (8 more chars):
$x>0&&qw{Mon Tues Wednes Thurs Fri Satur Sun}[$x-1]."day"||"Invalid"

Bash 74 48 + error message
A different approach since all other answers focus on storing the strings in some form.
read x;((0<x&&x<8))&&date -d2007010$x +%A||echo out of range

what is the byte count?

@proudhaskeller Irrelevant as this has not been tagged as [tag:code-golf]

you're right, just all other solutions have a byte count. weird.

That is more a POSIX sh answer. In bash you can use arithmetic evaluation. read x;((0<x&&x<8))&&date -d2007010$x +%A||echo out of range is shorter.

The question only stated that the program should not crash in case the number is not between 1 and 7, so you can just remove the ||echo out of range. Considering that the accepted solution doesn't follow the rules (print to stdout)... But if you want to follow the OP's example, you can use invalid instead of out of range.

Java 8 - 69 64 chars
Here's an expression in Java 8, including the import. Now improved (thanks to Tomáš Dvořák):
import java.time.*;
return DayOfWeek.of((i>0&i<8)?i:1).name();

Simply prints MONDAY for bogus values of i

Tip: .name() is shorter than .toString() and does the same thing. You can save 4 characters. Also you can use only one & instead of two and save another char.

Python - 87
I'm not seeing enough love for dict's .get()
This one expects a to be the number
dict(enumerate("mon,tues,wednes,thurs,fri,satur,sun".split(","),1)).get(a,"bad ")+"day"

You can save some characters by removing all occurrences of day in your list and add +"day" at the end of your code.

You can also save some characters by putting all days in one string and then split them instead of putting them all separately in the list: "mon,tues,...".split(",")

That works nicely, cheers :-)

Golfscript (50 55)
Expects the input number to be on the stack.
" Mon Tues Wednes Thurs Fri Satur Sun"" "/\="day"+

or
("Mon Tues Wednes Thurs Fri Satur Sun"" "/\="day"+

or (for 51, but it's just fun)
"day Mon Tues Wednes Thurs Fri Satur Sun"" "/.@=\0=

The requirement "not crash" is pretty lenient. This will just print "day" for invalid input – which is not a crash, so it should be allowed.

Cobra - 43
print if(0<n<8,(n%7)to DayOfWeek,'Invalid')

R, 61
a=format(Sys.Date()+0:15,"%A");a[grep("^M",a)[1]+0:6][scan()]

format(Sys.Date()+0:15,"%A") outputs the day of the week of today and the 15 following days. grep("^M",a)[1]+0:6 is the index of the first monday in that sequence and the six following days.
Usage:
> a=format(Sys.Date()+0:15,"%A");a[grep("^M",a)[1]+0:6][scan()]
1: 7
2:
Read 1 item
[1] "Sunday"
> a=format(Sys.Date()+0:15,"%A");a[grep("^M",a)[1]+0:6][scan()]
1: 4
2:
Read 1 item
[1] "Thursday"
> a=format(Sys.Date()+0:15,"%A");a[grep("^M",a)[1]+0:6][scan()]
1: 2
2:
Read 1 item
[1] "Tuesday"
> a=format(Sys.Date()+0:15,"%A");a[grep("^M",a)[1]+0:6][scan()]
1: 8
2:
Read 1 item
[1] NA

CJam - 47 or 45
qi"Sun Mon Tues Wednes Thurs Fri Satur"S/="day"

Try it at http://cjam.aditsu.net/
If I can assume that the number is already on the stack, then the first 2 characters can be removed.

C# - 28
According to your reference solution, this should be valid.
It assumes the input is stored in the variable i and outputs "Sunday", "Monday", etc for 0, 1, etc respectively.
If i is out of bounds (below 0 or above 7), i will be output. (This is valid because the program doesn't crash)
Console.Write((DayOfWeek)i);

If you actually want a working function, here is one using 48 bytes:
string f(int i){return((DayOfWeek)i)+"";}

Python - 83 76
from datetime import*
i=input()
if 0<i<8:print date(2013,7,i).strftime("%A")

July 2013 was the first month I found that had monday as its first day. Rest of this is quite self explanatory.

It's 82 bytes, don't count the trailing newline. You can use from datetime import* and date instead of import datetime as d and d.date (-1 byte), input() instead of int(input) (-5 bytes), and 1,1 instead of 2013,7 (-3 bytes).

Thanks for the suggestions! Although "1,1" as "year,month" does not work; ValueError: year=1 is before 1900; the datetime strftime() methods require year >= 1900

Python, 95 bytes
"%day"%["mon","tues","wednes","thurs","fri","satur","sun"][n-1] if 0<n<8 else "invalid"

monsday? Did I read that right?

Not sure where you got 95 bytes from, by my count it's 88. I managed to save 11 by fixing the "monsday" bug, using string concatenation instead of % formatting, creating the list from a string using split() and removing unnecessary whitespace.

"mon tues wednes thurs fri satur sun".split()[n-1]+"day"if 0<n<8else"invalid"

@undergroundmonorail you can save another 6 bytes by using single quotes instead of double quotes

@githubphagocyte I can't tell if you're joking or seriously mistaken regarding how many bytes quote characters take up.

@undergroundmonorail I was making a very poor joke.

@undergroundmonorail 87, actually. Don't count the trailing newline.

@nyuszika7h that comment was before githubphagocyte's edit

Python 2, 84 83 64
Assuming n is already stored as a variable.
import calendar as c;print c.day_name[n-1]if 0<n<8 else'Invalid'

From this comment, it does seem like input can be ignored.

C, 81
Just for fun...
printf("%sday\n","Mon\0Tues\0Wednes\0Thurs\0Fri\0Satur\0Sun"+"  $)06:@"[n&7]-32);

What's "just for fun" about this answer?

Java
Uses local language:
return i<1||i>7?"Error":new DateFormatSymbols().getWeekdays()[i];

You can use only one | instead of || to save one character. Also good idea to create new instance, instead of calling getInstance(). It is shorter. But without specific locale, your output for 1 can be "sunday", not "monday" (locale en_US).

C, 117
Also just for fun...
d(n){for(char*p="\177MvT|WpF S\177oxh`a`t\026uze|d;n|eHrrspi\001d\001a\001y\001\n";
*p;p++)-*p++&1<<n-1&&putchar(*p);}

(I realize this isn't an obfuscation challenge. I just wanted to see how far a purely data-driven bit-test loop could be golfed.)

The un-golfed version:
void d(int n)
{
  char *p =
    "\177" "M"   "\166" "T"   "\174" "W"   "\160" "F"   "\040" "S"
    "\177" "o"   "\170" "h"   "\140" "a"   "\140" "t"   "\026" "u"
    "\172" "e"   "\174" "d"   "\073" "n"   "\174" "e"   "\110" "r"
    "\162" "s"   "\160" "i"   "\001" "d"   "\001" "a"   "\001" "y"
    "\001" "\n";

  for (; *p; p++)
    if (-(*(p++)) & (1<<(n-1)))
      putchar(*p);
}

Driver:
int main() { for (int n = 1; n <= 7; n++) d(n); }

Output:
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday

How it works:

The character string consists of a pairs of bit-flags and output characters.
The even indexes are the bit-flags ('\177', 'v', '|', 'p', ' ', etc.) — but they are stored in ones-complement form to minimize the number of nonprintable ASCII values, which are expensive because they have to be encoded in octal.
The odd indexes are the output characters ('M', 'T', 'W', 'F', 'S', 'o', 'h', 'a', etc.).

Batch - 114 Bytes
@cmd/von/c"for %%a in (1Mon 2Tues 3Wednes 4Thur 5Fri 6Satur 7Sun)do @set a=%%a&if "!a:~0,1!"=="%1" echo !a:~1!day"

The first part @cmd/von/c is starting up a new cmd session - it uses the /v switch to enable delayed variable expansion, which saves adding in the lengthy setLocal enableDelayedExpansion. This way you only need to add the @ symbol (to hide output) before the cmd command and in the middle of the for loop, instead of @echo off at the start of the script.

PHP - 32
Day is given as $i
<?echo date('l',(($i+4)*86400));

Java 8, 48 chars
return n>0&n<8?DayOfWeek.of(n).name():"Invalid";

With java 8 comes new enum DayOfWeek, that provides non locale dependent data.
For java 7 and older, this should work good too (76 chars):
return n<1|n>7?"Invalid":DateFormatSymbols.getInstance().getWeekdays()[n+1];

And locale fixed variant (90 chars):
return <1|n>7?"Invalid":DateFormatSymbols.getInstance(Locale.ENGLISH).getWeekdays()[n+1];

bash - 18
date +%A -d01010$1

Save it in a file, e.g. day.sh, then run
./day.sh 1 # output: Monday
./day.sh 2 # output: Tuesday
...

Try: save it in a file script.sh and run: bash script.s 1, it will output "Monday". bash script.sh 2, it will output "Tuesday" etc...

Because 2001-01-01 was Monday, but you can notice that the last number is precedeed by a $, so it's a parameter.

R, 37
The obligatory hack solution with R.
weekdays(as.Date((paste0("1/1/",n))))

where the input is first stored as variable n. Turning this into a named function would be longer:
d=function(n) weekdays(as.Date((paste0("1/1/",n))))

Javascript - 63
'0Mon0Tues0Wednes0Thurs0Fri0Satur0Sun'.split(0)[prompt()]+'day'

This doesn't handle invalid input correctly.

The spec doesn't stipulate invalid input handling, only that the program doesn't crash

I stand corrected.

C# - 30
Since the provided example doesn't actually output, neither does this. Also I'm assuming we don't have to have an error message if the value is below 1 or over 7.
((DayOfWeek)(n%7)).ToString();

For an error message (47):
n<1|n>7?"Error":((DayOfWeek)(n%7)).ToString();

The reason for the %7 is because DayOfWeek begins with Sunday.
Small cheat: DayOfWeek is contained in the System namespace, so if using System; isn't specified elsewhere (usually always is), you'd need to replace DayOfWeek with System.DayOfWeek -- an additional 7 characters.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
fit 22 (perhaps 23) of a specific 3d pentacube into a 5x5 cube
Update: It seems that the original question at math.SE was solved, there should be no 23 pieces solution.
The original problem is stated here over at math.SE
The task is writing a program that fits 22 copies (or perhaps 23) of the following pentacube into a 5x5x5 cube (back and front view).

The pentacube must be placed within the grid (no 45° orientations and shifts of 0.5 etc.) of the big cube and can be rotated around any of the x,y,z axes in 90° steps.
Known up to now:
According to the math.SE question there is a solution for 22 pieces, but it is unknown whether there is a solution for 23 pieces. (24 again seems to be impossible).
Winning criteria
Rotatation and mirroring of one solution count all as the same solution. Finding all solutions means that the program must show that the solutions provided are really all possible solutions.
You will get (points will add up)

10 points for finding any 22 piece solution
20 points for finding two or more 22 piece solutions
50 points for finding all 22 piece solution
100 points for finding a 23 piece solution
200 points for finding two or more 23 piece solutions
500 points for finding all 23 piece solutions or showing that there is no 23 piece solution
1 point per vote

If two people have the same amount of points the one that postet first will win. Please explain your approach and show the solution/s (at least one if there is one.) Please also include your score (except votes) and the runtime in your answer. I discourage hardcoding answers. If you find solutions 'by hand' or if you find a mathematical proof you can also submit them, but please state this explicitly if you do so.
UPDATE: In the original post in math.SE now 64 solutions for 22 pieces have been found (non exhausive, and perhaps some of them are rotations/mirrorings of others). So I discourage just copying these solutions - but as long as you found them on your own this is ok!

Thank you for pointing out all ambiguities! I'd also accept a mathematical proof or a packing that was found by hand, since the primary goal is solving the problem=) So I think the ouput 'format' should not be restricted.

That is a nice idea thank you again. (But I think it is unlikely that a tiebreaker will be needed.)

do you have any specific wish on how to visualise the solutions?

No not at all, it just must be human readable but it does not matter whether you output an ASCII table or a 3D animation with an epic soundtrack=)

Is it 20 points for finding a second 22-piece solution (cumulative with the 10 for the first), or 10 additional points for the second giving a total of 20?

It is adding up, so if you got two 22 piece solutions you will earn at least 30 points.

Plane-based analysis, 30+ points
The basic idea is explained in the comment at the top of the class. This runs for about 8 minutes on my desktop and finds 90560 22-tile solutions, possibly including symmetrical ones; since a cube has only 48 isometries, that corresponds to at least 1887 distinct solutions. However, it doesn't guarantee that there are no more: only that if there are any more, they don't have two opposite exterior faces which contain 3 cubies each of 8.
Two sample solutions:
ddbee dubb. ruut. rlktt llkk.
adbbe aduee rrutt lrkjj lookj
aa.ff qa.f. .q.vv ioov. iiojj
ggchf qgcfh qqssv impnv mipnn
gcchh gcssh ...s. .m.pn mmppn

.ggff qqgf. .q.uu .llpu oolpp
bgddf bgvdf qqvu. ooiup ollip
bbdee rbdve rrvv. .mijj mmiij
hhcea rhcae .rstt kmsnt mknjj
hccaa hc.a. .sst. ks.nt kknn.

Checking for 23-tile solutions with the same principle is a matter of changing tilesInPlane2 to 7; it runs for about one minute and finds no solutions.
I suggest redirecting stdout to a file and watching the progress reports on stderr.
import java.util.*;

// Overall approach follows a strategy proposed by Ed Pegg.
// If we place one 8-tile board on plane 0 sticking into plane 1,
// and one 8-tile board on plane 4 sticking into plane 3,
// what can fit into plane 2 sticking into planes 1 and 3?
// Since an 8-tile plane occupies at least 16/25 of the adjacent plane, we're looking to fit 4/7 of the tiles from
// plane 2 into the gaps left by the tiles from plane 0, and then the remaining 3/7 into the gaps left
// by the tiles from plane 4.
public class CodeGolf36250 {
    // Bit mask: 25 bits indicating the "main" plane, 25 bits indicating the "adjacent" plane
    static final long mainPlane = (1L << 25) - 1;
    static final long adjPlane = ((1L << 25) - 1) << 25;

    static final int tilesInPlane2 = 6;
    static final int tilesInPlanes2_3 = (tilesInPlane2 + 1) / 2; // Half rounded up

    public static void main(String[] args) {
        Set<Long> primitives = new HashSet<Long>();
        for (int x = 0; x < 4; x++) {
            for (int y = 0; y < 4; y++) {
                int tl = x + y * 5;
                // We consider only positions where we put 3 cubies in the main plane and 2 in the adjacent plane.
                // Diagram format: main plane, adj plane
                // So we have
                //  c000 c100   c001 c101
                //  c010 c110   c011 c111
                long c000 = 1L << tl, c100 = c000 << 1, c010 = c000 << 5, c110 = c100 << 5;
                long c001 = c000 << 25, c101 = c100 << 25, c011 = c010 << 25, c111 = c110 << 25;
                // ##  .#  |  ##  #.  |  #.  #.  |  .#  .#
                // #.  #.  |  .#  .#  |  ##  .#  |  ##  #.
                primitives.add(c000 + c100 + c010 + c101 + c011);
                primitives.add(c000 + c100 + c110 + c001 + c111);
                primitives.add(c000 + c010 + c110 + c001 + c111);
                primitives.add(c100 + c010 + c110 + c101 + c011);
                // ##  .#  |  ##  ..  |  ##  #.  |  ##  ..
                // #.  .#  |  #.  ##  |  .#  #.  |  .#  ##
                primitives.add(c000 + c100 + c010 + c101 + c111);
                primitives.add(c000 + c100 + c010 + c011 + c111);
                primitives.add(c000 + c100 + c110 + c001 + c011);
                primitives.add(c000 + c100 + c110 + c011 + c111);
                // #.  .#  |  #.  ##  |  .#  #.  |  .#  ##
                // ##  .#  |  ##  ..  |  ##  #.  |  ##  ..
                primitives.add(c000 + c010 + c110 + c101 + c111);
                primitives.add(c000 + c010 + c110 + c001 + c101);
                primitives.add(c100 + c010 + c110 + c001 + c011);
                primitives.add(c100 + c010 + c110 + c001 + c101);
            }
        }

        // Building full sets of tiles in the two planes uses far too much memory in the intermediate numbers
        // (in particular, the 5-tile sets).
        // It's much more efficient to see what coverings of the main plane we get and then for the high-count
        // sets we care about, to expand them to the adjacent plane.
        List<Set<TileSet>> nTiles = new ArrayList<Set<TileSet>>();
        nTiles.add(new HashSet<TileSet>()); // 0 tiles
        nTiles.get(0).add(new TileSet());
        for (int n = 1; n < 9; n++) {
            Set<TileSet> next = new HashSet<TileSet>();
            for (TileSet board : nTiles.get(n - 1)) {
                for (long prim : primitives) {
                    if ((board.sum & prim) == 0) {
                        TileSet newBoard = new TileSet();
                        newBoard.addAll(board);
                        newBoard.add(prim & mainPlane);
                        next.add(newBoard);
                    }
                }
            }
            nTiles.add(next);
            System.err.println(n+" tiles: " + next.size());
        }

        // Needed for the expansion.
        Map<Long, Set<Long>> primsByMainPlane = new HashMap<Long, Set<Long>>();
        for (Long prim : primitives) {
            Set<Long> group = primsByMainPlane.get(prim & mainPlane);
            if (group == null) primsByMainPlane.put(prim & mainPlane, group = new HashSet<Long>());
            group.add(prim);
        }

        Map<Long, Set<TileSet>> boards8ByAdjGaps = new HashMap<Long, Set<TileSet>>();
        for (TileSet board8 : nTiles.get(8)) {
            for (TileSet expandedBoard8 : expand(board8, primsByMainPlane)) {
                long expansion = (~expandedBoard8.sum) & adjPlane;
                Set<TileSet> boards8 = boards8ByAdjGaps.get(expansion);
                if (boards8 == null) boards8ByAdjGaps.put(expansion, boards8 = new HashSet<TileSet>());
                boards8.add(expandedBoard8);
            }
        }
        System.err.println(boards8ByAdjGaps.size() + " distinct gap sets in plane next to full one");

        long solutions = 0;
        int progress = 0;
        for (TileSet board : nTiles.get(tilesInPlane2)) {
            // Each board is only expanded once, but we don't keep them all around so we save a lot of memory
            for (TileSet plane2 : expand(board, primsByMainPlane)) {
                for (Map.Entry<Long, Set<TileSet>> plane0 : boards8ByAdjGaps.entrySet()) {
                    solutions += countSolutions(plane0.getKey(), plane0.getValue(), plane2, boards8ByAdjGaps);
                }
            }

            progress++;
            // Progress reports are always good for long processes...
            if (progress % 1000 == 0) System.err.println("Progress: " + progress + "; solutions: " + solutions);
        }
    }

    private static Set<TileSet> expand(TileSet board, Map<Long, Set<Long>> primsByMainPlane) {
        Set<TileSet> bexps = new HashSet<TileSet>();
        bexps.add(new TileSet());
        for (Long tileBase : board) {
            Set<TileSet> nextBexps = new HashSet<TileSet>();
            for (TileSet bexp : bexps) {
                for (Long texp : primsByMainPlane.get(tileBase)) {
                    if ((bexp.sum & texp) == 0) {
                        TileSet nextBexp = new TileSet();
                        nextBexp.addAll(bexp);
                        nextBexp.add(texp);
                        nextBexps.add(nextBexp);
                    }
                }
            }
            bexps = nextBexps;
        }
        return bexps;
    }

    private static int countSolutions(long gaps1, Set<TileSet> planes0, TileSet plane2, Map<Long, Set<TileSet>> boards8ByAdjGaps) {
        int solutions = 0;
        int fitTiles = 0;
        long unfitTiles = 0;
        for (Long tile : plane2) {
            if ((tile & adjPlane) == (tile & gaps1)) fitTiles++;
            else unfitTiles |= tile;
        }

        if (fitTiles >= tilesInPlanes2_3) {
            for (Map.Entry<Long, Set<TileSet>> planes4 : boards8ByAdjGaps.entrySet()) {
                long gaps3 = planes4.getKey();
                if ((unfitTiles & adjPlane) == (unfitTiles & gaps3)) {
                    // The Cartesian product of planes0 and planes4.getValue() are all solutions with the same
                    // plane2
                    for (TileSet plane4 : planes4.getValue()) {
                        for (TileSet plane0 : planes0) {
                            printSolutions(plane0, plane2, unfitTiles, plane4);
                            solutions++;
                        }
                    }
                }
            }
        }

        return solutions;
    }

    private static void printSolutions(TileSet plane0, TileSet plane2, long unfitTiles, TileSet plane4) {
        char[][][] cube = new char[5][5][5];
        // plane0's main plane is 0
        char tileName = 'a';
        for (Long tile : plane0) {
            populatePlane(cube[0], tile & mainPlane, tileName);
            populatePlane(cube[1], tile >> 25, tileName);
            tileName++;
        }
        for (Long tile : plane4) {
            populatePlane(cube[4], tile & mainPlane, tileName);
            populatePlane(cube[3], tile >> 25, tileName);
            tileName++;
        }
        for (Long tile : plane2) {
            populatePlane(cube[2], tile & mainPlane, tileName);
            // The tricky bit: up or down? We look to unfitTiles.
            populatePlane(cube[(unfitTiles & tile) == 0 ? 1 : 3], tile >> 25, tileName);
            tileName++;
        }

        // Print as plane0 plane1 plane2 plane3 plane4
        for (int y = 0; y < 5; y++) {
            for (int z = 0; z < 5; z++) {
                for (int x = 0; x < 5; x++) {
                    System.out.print(cube[z][y][x] == 0 ? '.' : cube[z][y][x]);
                }
                System.out.print(' ');
            }
            System.out.println();
        }
        System.out.println();
        System.out.println();
    }

    private static void populatePlane(char[][] plane, long values, char tile) {
        for (int x = 0; x < 5; x++) {
            for (int y = 0; y < 5; y++) {
                if ((values & (1 << (x + 5*y))) != 0) {
                    if (plane[y][x] != 0) throw new IllegalStateException("Collision!");
                    plane[y][x] = tile;
                }
            }
        }
    }

    static class TileSet extends HashSet<Long> {
        private long sum = 0;

        @Override
        public boolean add(Long val) {
            if ((val & sum) != 0) throw new IllegalArgumentException();
            sum |= val;
            return super.add(val);
        }
    }
}

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/