text:
ROT-13 transform standard input
Task
Read a string of characters and produce the ROT13 of it. All characters besides [a-zA-Z] should be output verbatim. Each letter in the output may be in any case you wish (you do not have to preserve it).
ROT13 is a simple substitution cipher where each letter of the alphabet is rotated by 13 places (it doesn't matter whether you do it forward or backward, since ROT13 is it's own inverse).
Examples
Input
Output

Hello, world!
Uryyb, jbeyq!

Code Golf and Coding Challenges is awesome.
Pbqr Tbys naq Pbqvat Punyyratrf vf njrfbzr.

Mod abuse!1!!1
Zbq nohfr!1!!1

The problem shouldn't be a tag, so I removed ROT13, just an FYI

Don't you mean A-Za-z (to count both upper- and lower-case) ?

and make sure they don't use rot13 in standard library? like the PHP one

@Nakilon: (Re retag.) rot13 is not cryptography (at least not in the modern sense of the word).

@Chris Jester-Young, it belongs to this category at wikipedia. It's part of cryptography, just not the hardest one. Anyway, I'm not longer following this site. Community dissapointed me. Sorry. GL HF.

@Nakilon: That is like saying XOR (for a fixed value) is encryption. That's ludicrous. Also, sorry to hear you're leaving.

Saying xor is not encryption is like saying a+b is not math.

@Nakilon: Actually, I call that arithmetic, not mathematics. *shrug*

@Chris Jester-Young, I thought arithmetic is part of math ,.)

xor is encryption. rot13 is encoding, as is caesar-chiffre. (chiffre = encoding)

@Nakilon If you call arithmetic math, then you're probably also inclined to call spelling writing. I've never seen someone win a spelling bee and get called a writer for it. Just as doing fast arithmetic doesn't make you a mathematician.

@ChrisJester-Young: The only encryption which is provably safe, the one-time pad, is exactly the original message XORed with a fixed value (of the same length as the message).

Tags are used to categorize questions and help search similar questions. The [tag:cryptography] tag (from Greek kryptós, "hidden, secret"; and graphein, "writing") in particular is for encryption and decryption problems. All encryption and decryption, not only those that are secure for modern applications.

Bash, 23 bytes
Canonical 23-character answer:
tr A-Za-z N-ZA-Mn-za-m

I'm without access to bash at the moment, but I think this should work: tr A-za-m N-ZA-z (16 chars)

@Nabb: Nice to see you, GolfScript-meister! :-D I think your solution here would break the stipulation that "All characters besides A-Z should be copied to the output verbatim".

@Chris: Yep, looks like you're right.

@Nabb: No, to me it looks as if he's wrong. Or may you show an example?

@user unknown: Type in [\\]^_\`` in the input. It will come back as NOPQRSrather than[\]^_`, at least in the version of trI have. (Those are the six characters in ASCII that lie betweenZanda`. Obviously, all other characters will work correctly.)

You're right, I see.

Python 2, 34 bytes
print raw_input().encode('rot13')

-1 I think it is cheating that you are using a built in library.

I've used them in every code golf I took part in... Also if using python's standard lib is cheating, how is using tr not?

@Juan: There's no real "hard line", but a lot of it is about how specific the library is. Using transliteration to carry out ROT13 is fine, using the ROT13 builtin is cheating (or at best, a "joke solution").

@Anon In any case, it's an anwser you just ignore.. It's not off target, there's not any rules set by the OP nor by the community. Sure, maybe mine is not an award winning solution, like the one using tr that kicks ass. But it's not a joke, I'm leveraging the power of python to reduce the count, just like any other would do.

@Juan I'm just saying that pretty much every code-golf thing I've ever done specified that you cannot use built-in libraries that are specifically designed to solve the solution for you.

@Glenn: on the contrary, I have never seen a code-golf thing that say so. Neither do codegolf.com, golf.shinh.org or SPOJ SHORTEN.

See my comment on the other Python solution. raw_input() gives only one line.

@Glenn, I think library functions are fair game. It's up to the golf question to be interesting enough to not be in anyone's library or to specifically exclude.

Bash - 5 chars
rot13

Two downvotes so far (with no comments), but no downvotes for the question. I assume that means it's ok to ask trivial codegolfs but not to give the trivial answer. Harder codegolfs please!

Which bash-version? I don't have a build-in rot13. bash --version GNU bash, Version 4.0.33(1)-release (i486-pc-linux-gnu)

I'd have submitted this as rot13 - 0 chars... ;)

'tis coreutils my friend, not Bash

erm... no. my bash (Ubuntu 13.10) says "command not found, you can install this program by sudo apt-get install bsdgames"

Sorry but your not golfing here your running an application that does it for you and there for you not using bash your using the application 'rot13' however i did not downvote

rot13 is not in coreutils, so this isn't a bash solution or a bash+coreutils solution.

Befunge - 7x30 = 210 6x26 = 156 characters
New streaming version that supports both upper and lower case and should support unlimited input.
v,<               <<     <
  ^-4-9<    >:"A"\`|
     >:"a"\`|     #>:"Z"`|
>~:0`| #    >:"z"`|
,    @ |    <`"m":<v`"M":<
^  +4+9<    ^      <

The old version
This stores the values inside its own source code. Really shows off how horrible it is to try and output stored values in the same order that you receive them.  Only supports lowercase characters.
vp0p11:+1g11<      < <
v                    ^-4-9<
v    >:"a"\`|>:"z"`|>:"m"`|
>~:0`|      >^     >^#
                     ^+4+9<
     >$011g1+0p>12g1+:12p0g:v
               ^           ,_@

I'm not sure exactly what limitations this has, using http://www.quirkster.com/iano/js/befunge.html as the interpreter it does appear to break with large inputs.

You can remove the whitespace at the end of lines.

Ruby - 60 57 38 37 chars
Edit: And just realised Ruby strings have a tr method.
puts$<.read.tr'A-Za-z','N-ZA-Mn-za-m'

Test
input = "The challenge: To read an input of arbitrary length and produce the ROT13 of the input. All characters besides A-Z should be copied to the output verbatim, and case should be preserved if possible.

Any language that can read and write standard streams is fair game."

output = `echo '#{input}' | ruby golf-rot13.rb`

puts "Input:"
puts input
puts "-------"
puts "Output:"
puts output

Gives:
Input:
The challenge: To read an input of arbitrary length and produce the ROT13 of the input. All characters besides A-Z should be copied to the output verbatim, and case should be preserved if possible.

Any language that can read and write standard streams is fair game.
-------
Output:
Gur punyyratr: Gb ernq na vachg bs neovgenel yratgu naq cebqhpr gur EBG13 bs gur vachg. Nyy punenpgref orfvqrf N-M fubhyq or pbcvrq gb gur bhgchg ireongvz, naq pnfr fubhyq or cerfreirq vs cbffvoyr.

Nal ynathntr gung pna ernq naq jevgr fgnaqneq fgernzf vf snve tnzr.

You don't need the space after puts, and 'A-z' is a shortcut for 'A-Za-z'

@Ventro: Thanks, after a bit of testing it seems 'A-z' is actually 'A-Z[\]^_a-z', damn ascii having characters between Zanda`.

Essentially the same but 35 characters: puts gets.tr'A-Za-z','N-ZA-Mn-za-m'.

@Michael: Except gets only returns the first line, using $<.read reads until EOF.  The question doesn't say anything about whether the input can contain new lines so I just erred on the side of caution.

Fair enough, but since the exercise specification only mentioned "arbitrary length" but said nothing about newlines, I'd rather err on the side of brevity in codegolf ;-)

Updated for Ruby 1.8+ (36 chars, need brackets now)
$><<gets.tr('A-Za-z','N-ZA-Mn-za-m')

vim, 5 keystrokes
Assuming normal mode and that the text is already written in the buffer:
ggg?G
Or, fallowing vimgolf's conventions:
g?GZZ
You can also invoke it as a terminal command, something like this:
$ vim -c 'norm g?G' -
< your text here ...
... multiple lines if you want ...
... terminate input with ctrl+D on a blank line >

I guess the latter would count as a "program" of 8 characters (norm g?G)

norm g?G is short for normal g?G that makes 8 chars.

I think you can safely assume to start out on line 1, so the first gg can be left off. I would say 3 keystrokes when the file is open.

If we use vimgolf's conventions (you start in a vanilla vim having just opened the file, but need to save and quit) we also get 5 (g?GZZ).

R, 37 bytes
example("chartr");cat(rot(scan(,"")))

example("chartr") runs the examples for chartr, which includes the rot function, which is ROT13 by default....

tr/// solution in Perl (39 characters), boilerplate can be removed with -p:
while(<>){y/a-zA-Z/n-za-mN-ZA-M/;print}

Using -p (23 characters including the extra switch):
perl -pe'y/a-zA-Z/n-za-mN-ZA-M/'

Add 1 char for the p, but please remove the boilerplate!

C - 83 79 characters
main(c,b){while((c=getchar())>=0)b=c&96,putchar(isalpha(c)?b+1+(c-b+12)%26:c);}

Readable version:
#include <ctype.h>
#include <stdio.h>

int main(void)
{
    int c, base;

    while ((c = getchar()) >= 0) {
        if (isalpha(c)) {
            base = (c & 96) + 1; /* First letter of the upper or lower case. */
            c = base + (c - base + 13) % 26;
        }
        putchar(c);
    }

    return 0;
}

Are you including the headers you include in your count?

@JPvdMerwe: I didn't include any headers in the golfed version, nor did I need to.

You can use the coma operator before putchar to remove a pair of braces.

Could you explain main(c,b)? It's the first time i see this.

also you can write b=c&96 and move +1 inside putchar. I got your version down to 79 chars.

@Alexandru: main(c,b) abuses the fact that parameters without types default to int, so you don't have to say int c,b;.  This is a pretty common golfing technique for C.  Also, thanks for the suggestions.

@Alexandru most C compilers support main with any parameters. Also, the original C standard defines that an argument with no type is an int. Thus you get to declare ints without actually writing int.

One more thing: you can get rid of b, replace it with (c&96) and replace c-(c&96) with c%32. Down to 76.

Python (117 bytes)
Here's a Python version that avoids the rot13()-method.
import sys
print"".join([chr(x/32*32+1+(x%32+12)%26if 64<x<91or 96<x<123 else x)for x in map(ord,sys.stdin.read())])

raw_input returns one line not all input.

you need to import sys and use sys.stdin.read().

@Alexandru: will do

-2 bytes if you eliminate the [] to make the list comp a generator: https://tio.run/##FYxBCsMgEADvecUSCGhTLGoRAvlMqIoWo7Jaal5v7WmGOUy@qktR9O7PnLBCucqU0cc6z@ydfCQvh6Q9pLhJsfKVtOVPQRehvAX13Nu@8YSwqWFcSDChGGjUjtbARziPTBLq@xizUrWPDM2hCaW091I/1k7OhJDgG1BPPw

DC (111 108 for the dc itself)
Ok, here it is in (mostly) dc and some sed and od magic to get it into the right format for the code. If you don't count the input thing (echo -n MESSAGE |) it's 160 bytes:
od -An -t dC|sed 's/^\ *//;s/\ \{2,3\}/\n/g'|dc -e'[13+26%]sm[65-lmx65+]su[97-lmx97+]sl[96<b64<dPc]sa[91>c]sd[123>e]sb[lux]sc[llxdd]se[ddddlaxlrx]sy[?z0<y]dsrx'

As a point of interest, the dc programme itself is only a 108 bytes long, shorter than the non-library python version. It even preserves case and punctuation, and beats Javascript in the above submission! If only I could better parse the output of od, or better yet replace it altogether.
EDIT: It's worth noting that the question doesn't indicate a trailing new line 10P which saves me three further bytes.
EDIT 2: There's no specification for the format of the input, so I assume it's taken in as is convenient for my programme :P

Perl6 (54)
$*IN.lines».trans("a..zA..Z"=>"n..za..mN..ZA..M").say

PHP - 103 98 80 characters
(not using str_rot13())
<?=preg_replace('#[a-zA-Z]#e','chr(($x=ord("\0"))-$x%32+1+($x%32+12)%26)',`cat`);

Delphi, 110
var c:Char;begin repeat Read(c);Write(Chr(Ord(c)+(Ord(c in['A'..'M'])-Ord(c in['N'..'Z']))*13));until EOF;end.

var c:Char;begin repeat Read(c);Write(Chr(Ord(c)+(Ord(c in['A'..'M'])-Ord(c in['N'..'Z']))*13));until EOF;end. saves one character :)

@Wouter van Nifterick : Good spot! I'll update it accordingly

Haskell, 100 characters
a%b=([a..b]++)
main=interact$map$toEnum.((0%64$78%90$65%77$91%96$110%122$97%109$[123..])!!).fromEnum

LispLisp (16,636)
I'm sorry.
((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
  (lisp lisp))
 (((lisp (lisp (lisp (lisp lisp))))
   ((lisp (lisp (lisp lisp)))
    ((lisp (lisp (lisp (lisp lisp))))
     (((lisp (lisp (lisp (lisp lisp))))
       ((lisp (lisp (lisp lisp)))
        (((lisp (lisp (lisp (lisp lisp))))
          (((lisp (lisp (lisp (lisp lisp))))
            ((lisp (lisp (lisp lisp)))
             (lisp (lisp (lisp (lisp lisp))))))
           (((lisp (lisp (lisp (lisp lisp))))
             ((lisp (lisp (lisp lisp)))
              (lisp (lisp (lisp lisp)))))
            (((lisp (lisp (lisp (lisp lisp))))
              ((lisp (lisp (lisp lisp)))
               (lisp (lisp (lisp (lisp lisp))))))
             (((lisp (lisp (lisp (lisp lisp))))
               ((lisp (lisp (lisp lisp)))
                ((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))))
              (lisp (lisp (lisp lisp))))))))
         ((lisp (lisp (lisp lisp)))
          (lisp (lisp (lisp lisp)))))))
      (((lisp (lisp (lisp (lisp lisp))))
        ((lisp (lisp (lisp lisp)))
         (((lisp (lisp (lisp (lisp lisp))))
           (((lisp (lisp (lisp (lisp lisp))))
             ((lisp (lisp (lisp lisp)))
              (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
               ((lisp (lisp (lisp lisp)))
                (lisp (lisp (lisp lisp)))))))
            (((lisp (lisp (lisp (lisp lisp))))
              (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
               ((lisp (lisp (lisp lisp)))
                (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                 ((lisp (lisp (lisp lisp)))
                  ((lisp (lisp (lisp lisp))) (lisp lisp)))))))
             ((lisp (lisp (lisp lisp)))
              (((((lisp (lisp (lisp (lisp lisp))))
                  (((lisp (lisp (lisp (lisp lisp))))
                    ((lisp (lisp (lisp lisp)))
                     (lisp (lisp (lisp (lisp lisp))))))
                   (lisp (lisp (lisp lisp)))))
                 ((((lisp (lisp (lisp (lisp lisp))))
                    ((lisp (lisp (lisp (lisp lisp))))
                     (((lisp (lisp (lisp (lisp lisp))))
                       ((lisp (lisp (lisp lisp)))
                        (lisp (lisp (lisp (lisp lisp))))))
                      (lisp (lisp (lisp lisp))))))
                   (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                    (lisp lisp)))
                  (((lisp (lisp (lisp (lisp lisp))))
                    (((lisp (lisp (lisp (lisp lisp))))
                      ((lisp (lisp (lisp lisp)))
                       (lisp (lisp (lisp (lisp lisp))))))
                     (lisp (lisp (lisp lisp)))))
                   (lisp lisp))))
                (((lisp (lisp (lisp (lisp lisp))))
                  ((lisp (lisp (lisp lisp)))
                   ((lisp (lisp (lisp (lisp lisp))))
                    (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                     ((lisp (lisp (lisp lisp))) (lisp lisp))))))
                 (lisp (lisp (lisp lisp)))))
               ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                 (((lisp (lisp (lisp (lisp lisp))))
                   ((lisp (lisp (lisp lisp)))
                    ((((lisp (lisp (lisp (lisp lisp))))
                       (((lisp (lisp (lisp (lisp lisp))))
                         ((lisp (lisp (lisp lisp)))
                          (lisp (lisp (lisp (lisp lisp))))))
                        (lisp (lisp (lisp lisp)))))
                      (lisp lisp))
                     ((((lisp (lisp (lisp (lisp lisp))))
                        (((lisp (lisp (lisp (lisp lisp))))
                          ((lisp (lisp (lisp lisp)))
                           (lisp (lisp (lisp (lisp lisp))))))
                         (lisp (lisp (lisp lisp)))))
                       (((lisp (lisp (lisp (lisp lisp))))
                         (((lisp (lisp (lisp (lisp lisp))))
                           ((lisp (lisp (lisp lisp)))
                            (lisp (lisp (lisp (lisp lisp))))))
                          (lisp (lisp (lisp lisp)))))
                        (lisp lisp)))
                      (((lisp (lisp (lisp (lisp lisp))))
                        ((lisp (lisp (lisp lisp)))
                         ((lisp (lisp (lisp (lisp lisp))))
                          (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                           ((lisp (lisp (lisp lisp))) (lisp lisp))))))
                       (lisp (lisp (lisp lisp))))))))
                  (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                   ((lisp (lisp (lisp lisp)))
                    ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                      (lisp lisp))
                     (((lisp (lisp (lisp (lisp lisp))))
                       ((lisp (lisp (lisp lisp)))
                        (((lisp (lisp (lisp (lisp lisp))))
                          ((lisp (lisp (lisp lisp)))
                           ((lisp (lisp (lisp (lisp lisp))))
                            (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                             ((lisp (lisp (lisp lisp))) (lisp lisp))))))
                         (lisp (lisp (lisp lisp))))))
                      (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                       (lisp lisp))))))))
                (((lisp (lisp (lisp (lisp lisp))))
                  ((lisp (lisp (lisp lisp)))
                   ((((lisp (lisp (lisp (lisp lisp))))
                      (((lisp (lisp (lisp (lisp lisp))))
                        ((lisp (lisp (lisp lisp)))
                         (lisp (lisp (lisp (lisp lisp))))))
                       (lisp (lisp (lisp lisp)))))
                     (((lisp (lisp (lisp (lisp lisp))))
                       ((lisp (lisp (lisp lisp)))
                        (((lisp (lisp (lisp (lisp lisp))))
                          (((lisp (lisp (lisp (lisp lisp))))
                            ((lisp (lisp (lisp lisp)))
                             (lisp (lisp (lisp (lisp lisp))))))
                           (lisp (lisp (lisp lisp)))))
                         (((lisp (lisp (lisp (lisp lisp))))
                           (((lisp (lisp (lisp (lisp lisp))))
                             ((lisp (lisp (lisp lisp)))
                              (lisp (lisp (lisp (lisp lisp))))))
                            (lisp (lisp (lisp lisp)))))
                          (lisp lisp)))))
                      ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                        (lisp lisp))
                       (((lisp (lisp (lisp (lisp lisp))))
                         (((lisp (lisp (lisp (lisp lisp))))
                           ((lisp (lisp (lisp lisp)))
                            (lisp (lisp (lisp (lisp lisp))))))
                          (lisp (lisp (lisp lisp)))))
                        (lisp lisp)))))
                    (((lisp (lisp (lisp (lisp lisp))))
                      ((lisp (lisp (lisp lisp)))
                       ((lisp (lisp (lisp (lisp lisp))))
                        (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                         ((lisp (lisp (lisp lisp)))
                          ((((lisp (lisp (lisp (lisp lisp))))
                             (((lisp (lisp (lisp (lisp lisp))))
                               ((lisp (lisp (lisp lisp)))
                                (lisp (lisp (lisp (lisp lisp))))))
                              (lisp (lisp (lisp lisp)))))
                            (((lisp (lisp (lisp (lisp lisp))))
                              ((lisp (lisp (lisp lisp)))
                               (((lisp (lisp (lisp (lisp lisp))))
                                 (((lisp (lisp (lisp (lisp lisp))))
                                   ((lisp (lisp (lisp lisp)))
                                    (lisp (lisp (lisp (lisp lisp))))))
                                  (lisp (lisp (lisp lisp)))))
                                (((lisp (lisp (lisp (lisp lisp))))
                                  (((lisp (lisp (lisp (lisp lisp))))
                                    ((lisp (lisp (lisp lisp)))
                                     (lisp (lisp (lisp (lisp lisp))))))
                                   (lisp (lisp (lisp lisp)))))
                                 (lisp lisp)))))
                             ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                               (lisp lisp))
                              (((lisp (lisp (lisp (lisp lisp))))
                                (((lisp (lisp (lisp (lisp lisp))))
                                  ((lisp (lisp (lisp lisp)))
                                   (lisp (lisp (lisp (lisp lisp))))))
                                 (lisp (lisp (lisp lisp)))))
                               (lisp lisp)))))
                           ((lisp (lisp (lisp (lisp lisp))))
                            (((lisp (lisp (lisp (lisp lisp))))
                              ((lisp (lisp (lisp lisp)))
                               (lisp (lisp (lisp (lisp lisp))))))
                             (lisp (lisp (lisp lisp)))))))))))
                     (lisp (lisp (lisp lisp)))))))
                 ((((lisp (lisp (lisp (lisp lisp))))
                    (((lisp (lisp (lisp (lisp lisp))))
                      ((lisp (lisp (lisp lisp)))
                       (lisp (lisp (lisp (lisp lisp))))))
                     (lisp (lisp (lisp lisp)))))
                   (((lisp (lisp (lisp (lisp lisp))))
                     ((lisp (lisp (lisp lisp)))
                      (((lisp (lisp (lisp (lisp lisp))))
                        (((lisp (lisp (lisp (lisp lisp))))
                          ((lisp (lisp (lisp lisp)))
                           (lisp (lisp (lisp (lisp lisp))))))
                         (lisp (lisp (lisp lisp)))))
                       (((lisp (lisp (lisp (lisp lisp))))
                         (((lisp (lisp (lisp (lisp lisp))))
                           ((lisp (lisp (lisp lisp)))
                            (lisp (lisp (lisp (lisp lisp))))))
                          (lisp (lisp (lisp lisp)))))
                        (lisp lisp)))))
                    ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                      (lisp lisp))
                     (((lisp (lisp (lisp (lisp lisp))))
                       (((lisp (lisp (lisp (lisp lisp))))
                         ((lisp (lisp (lisp lisp)))
                          (lisp (lisp (lisp (lisp lisp))))))
                        (lisp (lisp (lisp lisp)))))
                      (lisp lisp)))))
                  (((lisp (lisp (lisp (lisp lisp))))
                    ((lisp (lisp (lisp lisp)))
                     ((lisp (lisp (lisp (lisp lisp))))
                      (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                       ((lisp (lisp (lisp lisp)))
                        (((lisp (lisp (lisp (lisp lisp))))
                          ((lisp (lisp (lisp lisp)))
                           (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                            ((lisp (lisp (lisp lisp)))
                             (lisp (lisp (lisp lisp)))))))
                         (((lisp (lisp (lisp (lisp lisp))))
                           (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                            ((lisp (lisp (lisp lisp)))
                             (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                              ((lisp (lisp (lisp lisp)))
                               ((lisp (lisp (lisp lisp))) (lisp lisp)))))))
                          ((lisp (lisp (lisp lisp)))
                           (((((lisp (lisp (lisp (lisp lisp))))
                               (((lisp (lisp (lisp (lisp lisp))))
                                 ((lisp (lisp (lisp lisp)))
                                  (lisp (lisp (lisp (lisp lisp))))))
                                (lisp (lisp (lisp lisp)))))
                              (((lisp (lisp (lisp (lisp lisp))))
                                ((lisp (lisp (lisp lisp)))
                                 (((lisp (lisp (lisp (lisp lisp))))
                                   (((lisp (lisp (lisp (lisp lisp))))
                                     ((lisp (lisp (lisp lisp)))
                                      (lisp (lisp (lisp (lisp lisp))))))
                                    (lisp (lisp (lisp lisp)))))
                                  (((lisp (lisp (lisp (lisp lisp))))
                                    (((lisp (lisp (lisp (lisp lisp))))
                                      ((lisp (lisp (lisp lisp)))
                                       (lisp (lisp (lisp (lisp lisp))))))
                                     (lisp (lisp (lisp lisp)))))
                                   (lisp lisp)))))
                               ((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                                 (lisp lisp))
                                (((lisp (lisp (lisp (lisp lisp))))
                                  (((lisp (lisp (lisp (lisp lisp))))
                                    ((lisp (lisp (lisp lisp)))
                                     (lisp (lisp (lisp (lisp lisp))))))
                                   (lisp (lisp (lisp lisp)))))
                                 (lisp lisp)))))
                             (((lisp (lisp (lisp (lisp lisp))))
                               ((lisp (lisp (lisp lisp)))
                                ((lisp (lisp (lisp (lisp lisp))))
                                 (((lisp (lisp (lisp (lisp lisp))))
                                   (lisp lisp))
                                  ((lisp (lisp (lisp lisp))) (lisp lisp))))))
                              (lisp (lisp (lisp lisp)))))
                            (((((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
                               (lisp lisp))
                              (((lisp (lisp (lisp (lisp lisp))))
                                ((lisp (lisp (lisp lisp)))
                                 ((lisp (lisp (lisp (lisp lisp))))
                                  (((lisp (lisp (lisp (lisp lisp))))
                                    ((lisp (lisp (lisp lisp)))
                                     (lisp (lisp (lisp (lisp lisp))))))
                                   (((lisp (lisp (lisp (lisp lisp))))
                                     ((lisp (lisp (lisp lisp)))
                                      ((lisp (lisp (lisp (lisp lisp))))
                                       (lisp lisp))))
                                    (lisp (lisp (lisp lisp))))))))
                               (((lisp (lisp (lisp (lisp lisp))))
                                 ((lisp (lisp (lisp lisp)))
                                  ((lisp (lisp (lisp (lisp lisp))))
                                   ((lisp (lisp (lisp lisp)))
                                    (lisp (lisp (lisp lisp)))))))
                                (((lisp (lisp (lisp (lisp lisp))))
                                  (((lisp (lisp (lisp (lisp lisp))))
                                    ((lisp (lisp (lisp lisp)))
                                     (lisp (lisp (lisp (lisp lisp))))))
                                   (((lisp (lisp (lisp (lisp lisp))))
                                     ((lisp (lisp (lisp lisp)))
                                      (lisp (lisp (lisp lisp)))))
                                    (((lisp (lisp (lisp (lisp lisp))))
                                      (lisp lisp))
                                     (lisp lisp)))))
                                 ((lisp (lisp (lisp lisp)))
                                  ((lisp (lisp (lisp (lisp lisp))))
                                   (((lisp (lisp (lisp (lisp lisp))))
                                     ((lisp (lisp (lisp lisp)))
                                      (lisp (lisp (lisp (lisp lisp))))))
                                    (lisp (lisp (lisp lisp))))))))))
                             ((lisp (lisp (lisp lisp))) (lisp lisp))))))))))))
                   (lisp (lisp (lisp lisp))))))))))))
          (lisp lisp))))
       (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
        ((lisp (lisp (lisp lisp)))
         (lisp (lisp (lisp lisp))))))))))
  (((lisp (lisp (lisp (lisp lisp))))
    (((lisp (lisp (lisp (lisp lisp))))
      ((lisp (lisp (lisp lisp)))
       (lisp (lisp (lisp (lisp lisp))))))
     (((lisp (lisp (lisp (lisp lisp))))
       ((lisp (lisp (lisp lisp)))
        (lisp (lisp (lisp lisp)))))
      (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
       (lisp lisp)))))
   ((lisp (lisp (lisp lisp)))
    (((lisp (lisp (lisp (lisp lisp)))) (lisp lisp))
     ((lisp (lisp (lisp lisp)))
      ((lisp (lisp (lisp lisp))) (lisp lisp))))))))

Is this an actual language with an implementation? If so, can you please link to it?

@JoKing Wikipedia TIO

@BenjaminUrquhart Yes, Lisp is a language. Lisplisp however, I have found no evidence exists

@JoKing oh I see. Maybe he was referring to this?

@BenjaminUrquhart No, that's just another Lisp interpreter

Here's a translator to LazyK (Itself simply an implementation of the SKI Combinator Calculus). https://gist.github.com/SYZYGY-DEV333/d74ca36b9a4c504b25c0a2380203c98d

C (clang), 200 164 113 86 bytes
main(){char*s,*t=s;for(gets(s);*s;s++)isalpha(*s)?*s+=(*s&~32)<78?13:-13:0;printf(t);}

Try it online!
This uses a for-loop which converts each letter into ROT13 using their ASCII values to use lesser bytes. scanf()'s parameters are now longer to include spaces in the string, since the previous code revision can't take spaces for input, so now it's longer.
Thanks to ceiling cat for golfing 36 bytes. Thanks to EasyasPi, with the help of ceilingcat, for golfing 51 bytes. Thanks to a stone arachnid for golfing 27 bytes.

Welcome to Code Golf Stack Exchange, Code Golf Stack Exchange! Nice first answer. I don't know C at all, but it looks like bitwise operators work to save bytes. Nice username as well.

151 bytes Only In Code Golf™

86 bytes using bitwise arithmetic and the isalpha() function from ctype.h

PHP - 41 Characters
while($r=fgets(STDIN))echo str_rot13($r);

-1 for rep-whoring.

Python 3 (107)
Ok, I promise to stop answering this question now, but I felt compelled to beat the DC answer in Python.  This probably reflects poorly on me as a person :).
import sys;[print(x.isalpha()and chr((ord(x)&96)+1+(ord(x)%32+12)%26)or x,end='')for x in sys.stdin.read()]

C: 69 68 characters
Alright, I know this thread is long dead, but I couldn't stand the (long) C-solution which doesn't even compile on Clang (but does on GCC).
main(c){putchar(isalpha(c=getchar())*((c|32)<110?13:-13)+c);main();}

It is probably almost still squeezable. It certainly was squeezable. And not only was it squeezable, it was possible to make it recursive.

CHIQRSX9+, 1
R

You just have to use the right tool for the problem.
CHIQRSX9+ is Turing complete, and it can read and write from standard channels with C.

The language you use should not be invented just for solving this particular code golf. It's been done, trust us, and the joke is old hat. -- Source

@nyuszika7h The language was invented before this question was written, so it is valid.

It's still one of the things it was invented for, though. Seems like cheating to me.

@nyuszika7h And golfscript was invented to win in code-golf challenges. Do you think that is cheating too?

CHIQRSX9+ is not a programming language by our usual standards. It does not have a clear specification on the X instruction, and because the RNG is not seeded, the output of the X instruction in the Perl implementation is not consistent across runs, therefore not following a consistent transformational model. This should be deleted.

@Mego It's hardly fair to apply those standards here when they were written a year after this answer.

@Mego Does it really matter? If you can find an already existing language that can do the job in 1 character, something is wrong with the question. I'm probably the idiot responsible for all that stupid rules. And the Meta-CodeGolf family is still not forbidden by this definition.

MetaGolfScript is forbidden by a different rule

The updated interpreter by ChristopherPeart can satisfy all of the above requirements.

05AB1E, 13 12 bytes
Saved a byte thanks to robbie0630
ADu)øJD2äRJ‡

Try it online!
Explanation
ADu           # push lower-case and uppercase alphabet
   )øJ        # zip, flatten and join, producing aAbB..zZ
      D2äRJ   # split a copy in 2 pieces, reverse and join producing nNoO..mM
           ‡  # translate input by replacing members of the alphabet
              # with the corresponding member of the rot-13 alphabet
              # implicitly display

I ran through this with --debug, and it seems like the ˜ is a no-op in this case and can be cut out.

@robbie0630: True. No idea why I had that in. Thank you :)

x86-16 Machine Code, IBM PC DOS, 37 bytes
Binary:
00000000: b408 cd21 3c20 7e1c 8ad0 0c20 3c61 7c0e  ...!< ~.... <a|.
00000010: 3c7a 7f0a b60d 3c6e 7c02 b6f3 02d6 b402  <z....<n|.......
00000020: cd21 ebdc c3                             .!...

Build and test using xxd -r
Unassembled listing:
        START:
B4 08       MOV  AH, 8          ; DOS API read char from STDIN (no echo)
CD 21       INT  21H            ; read char into AL
3C 20       CMP  AL, ' '        ; is any non-printable control char?
7E 1C       JL   EXIT           ; if so, end
8A D0       MOV  DL, AL         ; save original char in DL
0C 20       OR   AL, 'a'-'A'    ; lowercase the char
3C 61       CMP  AL, 'a'        ; is char less than 'a'?
7C 0E       JL   WRCHR          ; if so, do not convert
3C 7A       CMP  AL, 'z'        ; is char greater than 'z'?
7F 0A       JG   WRCHR          ; if so, do not convert
B6 0D       MOV  DH, 'n'-'a'    ; add or subtract 13
3C 6E       CMP  AL, 'n'        ; is char less than 'n'?
7C 02       JL   ADD13          ; if so, add 13
B6 F3       MOV  DH, 'a'-'n'    ; otherwise add -13
        ADD13:
02 D6       ADD  DL, DH         ; add 13 or -13
        WRCHR:
B4 02       MOV  AH, 2          ; DOS API write char to STDOUT
CD 21       INT  21H            ; write char in DL
EB DC       JMP  START          ; keep looping
        EXIT:
C3           RET                ; return to DOS

As a standalone PC DOS executable program.  Input is via STDIN, output to STDOUT.

Re-submitting answer to conform to STDIN challenge requirement.

Java 251 chars
public class r{public static void main(String[] a){String s = a[0];for(int i=0;i<s.length();){char c=s.charAt(i++);if(c>='a'&&c<='m')c+=13;else if(c>='n'&&c<='z')c-= 13;else if(c>='A'&&c<='M')c+=13;else if(c>='A'&&c <='Z')c-=13;System.out.print(c);}}}

Javascript (165)
a=prompt();y="ABCDEFGHIJKLMNOPQRSTUVWXYZ";b=y[s="substr"](13)+y[s](0,13);y+=y[l="toLowerCase"]();b+=b[l]();o='';for(i=0;a[i];i++)o+=b[y.indexOf(a[i])]||a[i];alert(o)

or (167) as previous Javascript solution, assuming readLine and print:
a=readLine();y="ABCDEFGHIJKLMNOPQRSTUVWXYZ";b=y[s="substr"](13)+y[s](0,13);y+=y[l="toLowerCase"]();b+=b[l]();o='';for(i=0;a[i];i++)o+=b[y.indexOf(a[i])]||a[i];print(o)

C, 136 bytes
I have never felt like any of my solutions are good enough to post on here, but made this for fun, and figured that it will be my gateway drug into code golf.
#define z(x) c>=x&&c<x+13
#define q(w) c>=w&&c<w+13
main(c){for(;(c=getchar())>=0;putchar(z('A')||z('a')?c+13:q('M')||q('m')?c-13:c));}

Welcome to Programming Puzzles and Code Golf Stack Exchange. Great first answer. And just for the record, we all feel that way sometimes, just know that anything that you create is "good enough" somewhere.

Everything here on PPCG is just for fun (or imaginary internet points) -- please, don't feel the work you've done to craft a solution isn't "good enough"

Thanks for all the support.  I think posting something was all I needed to get my head in gear.  I am going to try my hand at more of these challenges soon.

><>, 49 bytes
0i::"{`"@(@)*84**-::"AZ"@(@)+:}?$"4"-2d*%"A"+{?$o

Try it online
Explanation
0i
On each loop we initialize the stack with 0 and an input character.
The 0 will be used as a dummy to perform rot-13 operations on when the input isn't a letter.
::"{`"@(@)*84**-
Convert lowercase letters into uppercase for easier future operations.
::"AZ"@(@)+:}?$
If the character isn't an uppercase letter, use the 0 instead.
"4"-2d*%"A"+
ROT-13 operation. Subtract 52, mod by 13 and add 65 to get an uppercase letter.
{?$
If the character wasn't an uppercase before the ROT-13 operations, use the saved character instead.
o
Print as a character.

Haskell - 112 characters
r l=drop 13 l++take 13 l
t=['a'..'z']
s=['A'..'Z']
main=interact$map(\x->maybe x id$lookup x$zip(t++s)$r t++r s)

JavaScript 1.8, 106
alert(prompt().replace(/\w/g,function(c)String.fromCharCode(c.charCodeAt()+(c.toLowerCase()<'n'?13:-13))))
JavaScript, 115
alert(prompt().replace(/\w/g,function(c){return String.fromCharCode(c.charCodeAt()+(c.toLowerCase()<'n'?13:-13))}))
This solution solves the problem by adding 13 to the character code if the character in question is in the first half of the alphabet, or subtracting 13 if it's in the second half.

You can save 7 characters by replacing +(c.toLowerCase()<'n'?13:-13)) with -13+26*/[a-m]/i.test(c).

Jolf, noncompeting (language postdates challenge)
Jolf, 3 bytes
Try it here!
,Ri
,R  rot13
  i the input

Or, with new implicit input, ,R.
I'm sorry, but I'm not. I implemented this because it appears often in code-breaking puzzles, which I use Jolf a lot for, and recently used in an ARG. \o/
A longer one (try that one here):
ρi"[%]"γpWpud.pWp2pu+t3 iγH
ρi                           regex replace input
  "[%]"                      "[...]" following
        pWpu                 "abc...xyzABC....XYZ"
       γ                     γ = that
            d                functional replace
             .         _iγH  the index on the alphabet that the element is
                p2pu         shift uppercase alphabet
                    +t3      over thirteen
              pW             upper + lower of that

Julia 1.0, 69 bytes
(x->(c=Char(x);print(c+isletter(c)*13*(-1)^(x&31>13)))).(read(stdin))

Try it online!
Explanation
Most of the code is an anonymous function that takes an integer codepoint and prints the corresponding ROT-13'd character:
x->(c=Char(x);print(c+isletter(c)*13*(-1)^(x&31>13)))

x->(                                                )  # Anonymous function of x
    c=Char(x);                                         # Cast x to Char and save as c
                    c+                                 # Start with c and add to its codepoint:
                      isletter(c)*                     # If c is not a letter, the rest of this is
                                                       # multiplied by 0
                                  13*(-1)^(       )    # 13, times +/- 1 according to:
                                           x&31>13     # Low 5 bits of x are greater than 13
                                                       # I.e. x > 'M' (if x is uppercase) or x > 'm'
                                                       # (if x is lowercase)
              print(                               )   # Output the resulting character

We then apply this function, vectorized, to the array of (integer) codepoints returned by read(stdin).

65 bytes

JavaScript (Node.js), 65 bytes
o=>(b=Buffer)(b(o).map(c=>c%32<26&c>64?(c%32+13)%26+c-c%32:c))+''

Try it online!
o=>(                    // Define a function taking o and r
  b = Buffer            // Assign b to Buffer
)(                      // And call on...
  b(o).map(c=>          // a Buffer of the charcodes of o, mapped to...
    c%32<26&c>64        // If the character is alphabetical - charcode%32 is less than 26, charcode is >64
      ?                 // Then
    (c%32+13)%26+c-c%32 // Rot-13 the character - Mod 32, add 13, mod 26, add correct number depending on whether it's uppercase of lowercase.
    :c)                 // Else return the original string
 ) + ''                 // Coerce to string

Atto-8 Machine Code, 23 bytes
Decoded as hex:
E8 00 E0 C0 20 A0 61 84 00 0D 85 0D 90 0D 85 F2 90 D0 80 00 E1 01 E3

Commented disassembly listing:
# Generated by Dasm

main!
  nop @dyn        # padding for alignment
  x00 lda         # read from standard input
  ld0 x20 orr     # clone and convert to lowercase
  x61 sub         # map lowercase alphabet to 0-25
  x00             # default offset is 0
  x0D su2 x0D iff # if between a-m, offset is 13
  x0D su2 xF2 iff # if between n-z, offset is -13
  st0 add         # add offset to original input
  x00 sta         # write to standard output
  x01 sti         # loop back to start

K, 31
{x^(,/{x!(13_x),13#x}'.Q`A`a)x}

{x^a(,/-13 13#\:a:.Q.A)?x} for 26 bytes

Assuming only rot13'ing upper case letters is acceptable, {x^a(,/|0 13_a:.Q.A)?x} for 23 bytes. Handling both upper and lower case can be done in 29 by swapping the inner lambda in @tmartin's answer for {x!,/|0 13_x}.

Tcl, 74 chars
package require [set c tcl::transform::rot];$c 13 stdin;fcopy stdin stdout

pyg-i - 76 Bytes
P(STDI.read().t({a:a-13 if(77<a<91)or a>109 else a+13 for a in M(ord,STl)}))

Python Equivient:
import sys,string
print(sys.stdin.read().translate({a:a-13 if(77<a<91)or a>109 else a+13 for a in map(ord,string.ascii_letters)}))

Invalid because the interpreter is not available.

@cat Somehow I got the url wrong. It is fixed now.

Haskell (103)
Reused maybe c id $ lookup c from jloy's answer.
main=interact$map(\c->maybe c id$lookup c$[['a'..'z'],['A'..'Z']]>>=zip<*>uncurry(flip(++)).splitAt 13)

Python: 60 bytes
lambda s:''.join([chr((ord(c.lower())-84)%26+97)for c in s])

The only thing I don't like is having that .lower() in there. Any suggestions?
edit: I can get rid of the .lower(), and handle capitals better, but it's 94 bytes now:
lambda s:''.join([chr((ord(c)-(52if ord(c)<97else 84))%26+(65if ord(c)<97else 97))for c in s])

C#, 94 bytes
s=>{var r="";foreach(var c in s)r+=(char)(Char.IsLetter(c)?(c|32)<110?c+13:c-13:c);return r;};

Anonymous function which returns the string of characters rotated by 13 places, based on this C answer from Fors. Works for any lower or upper letters while keeping other input the same.
Full program with ungolfed method and test cases:
using System;

namespace ROT13
{
    class Program
    {
        static void Main(string[] args)
        {
            Func<string, string> f =
            s =>
            {
                var r = "";
                foreach (var c in s)
                    r += (char)(Char.IsLetter(c) ? (c | 32) < 110 ? c + 13 : c - 13 : c);
                return r;
            };

            Console.WriteLine(f("TOO MANY SECRETS!"));   // GBB ZNAL FRPERGF!
            Console.WriteLine(f("too many secrets!"));   // gbb znal frpergf!
            Console.WriteLine(f("gbb znal frpergf!"));   // too many secrets!
            Console.WriteLine(f("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,./"));
// NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm1234567890,./
        }
    }
}

Befunge-93, 72 67 bytes
Edit: -5 bytes thanks to James Holderness
<,<v!:+*"a"*`"`"\`\"{":\*"G"*`"@"\`\"[":::_@#+1:~
+0|_\"N"%6-55*1+%

Try it online!
Kinda disappointed in the previous Befunge answers, so I wrote one with much less whitespace.

Jelly, 12 bytes
ØAṙ13,µ;Œlyɠ

Try it online!
This takes input from STDIN
How it works
ØAṙ13,µ;Œlyɠ - Main link. Takes no arguments
ØA           - "ABC...XYZ"
  ṙ13        - Rotate 13 steps to the left
     ,       - Pair with the unaltered alphabet
      µ      - Begin a new link with ['NOP...KLM', 'ABC...XYZ'] as argument
        Œl   - Lowercase; ['nop...klm', 'abc..xyz']
       ;     - Concatenate; ['NOP...KLM', 'ABC...XYZ', 'nop...klm', 'abc..xyz']
           ɠ - Read a line from STDIN
          y  - Transliterate

Retina, 13 bytes
13+T`zlZL`l_L

Try it online!
The straightforward transliteration that directly applies ROT13 would be 2 bytes longer Try it online!
Explanation
The transliteration stage here is wrapped in a loop stage making it run 13 times (or until the string is not transformed anymore, which can only happen if the input string has no alphabetic characters).
In the transliteration, characters in zlZL are transformed into the characters at the same positions in l_L. Here, z and Z are exactly what they look like, while l and L get converted into the lowercase and uppercase alphabets. The final letters of those alphabets are ignored because they already appear earlier in the string, and _ is just a placeholder to make the uppercase alphabet line up correctly. The result is transforming each letter into the next one (a->b,b->c,...,z->a); doing this 13 times is ROT13.

Powershell, 77 bytes
-join($args|% t*y|%{[char]((("$_"-match'[a-m]')-("$_"-match'[n-z]'))*13+$_)})

Test script:
$f = {

-join($args|% t*y|%{[char]((("$_"-match'[a-m]')-("$_"-match'[n-z]'))*13+$_)})

}

@(

,("Hello!","Uryyb!")
,("HELLO","URYYB")
,("URYYB","HELLO")
,("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm")
,("Why did the chicken cross the road?
Gb trg gb gur bgure fvqr!",
"Jul qvq gur puvpxra pebff gur ebnq?
To get to the other side!")

) | % {
    $s,$expected = $_
    $result = &$f $s
    "$($result-eq$expected): $result"
}

Output:
True: Uryyb!
True: URYYB
True: HELLO
True: NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm
True: Jul qvq gur puvpxra pebff gur ebnq?
To get to the other side!

Python 3, 70 bytes
a=input()
for i in a:print(end=i.isalpha()*chr(65+(ord(i)-52)%26)or i)

Your proposed solution does not work with lowercase letters. It's not explicitely specified in the challenge though, so I'm not sure if your answer is valid.

PHP - 27 Bytes
<?=str_rot13(fgets(STDIN));

naz, 176 bytes
2a2x1v6a8m2x2v9a4a2x3v9a5a2x4v5a2x5v9a4a2x6v9a5a2x7v1x1f1r3x1v7e3x5v5g3x2v2g8f0x1x2f3x4v3l8f0x1x3f3x3v4g9a4a8f0x1x4f9s4s8f0x1x5f3x7v6l8f0x1x6f3x6v4g9a4a8f0x1x7f0a0x1x8f1o1f0x1f

The most involved naz solution I've written so far. This program subtracts 13 from every letter in standard input that's greater than M, and adds 13 to every other letter - whether lowercase or uppercase.
It does use a lot of logic to determine what's a letter or not, so I wouldn't be surprised if this could be improved upon.
Works for any input string terminated with the control character STX (U+0002).
Explanation (with 0x commands removed)
2a2x1v                     # Set variable 1 equal to 2
6a8m2x2v                   # Set variable 2 equal to 64 ("@")
9a4a2x3v                   # Set variable 3 equal to 77 ("M")
9a5a2x4v                   # Set variable 4 equal to 91 ("[")
5a2x5v                     # Set variable 5 equal to 96 ("`")
9a4a2x6v                   # Set variable 6 equal to 109 ("m")
9a5a2x7v                   # Set variable 7 equal to 123 ("{")
1x1f                       # Function 1
    1r                     # Read a byte of input
      3x1v7e               # Jump to function 7 if it equals variable 1
            3x5v5g         # Jump to function 5 if it's greater than variable 5
                  3x2v2g   # Jump to function 2 if it's greater than variable 2
                        8f # Otherwise, jump to function 8
1x2f                       # Function 2
    3x4v3l                 # Jump to function 3 if the register is less than variable 4
          8f               # Otherwise, jump to function 8
1x3f                       # Function 3
    3x3v4g                 # Jump to function 4 if the register is greater than variable 3
          9a4a             # Otherwise, add 13 to the register,
              8f           # then jump to function 8
1x4f                       # Function 4
    9s4s8f                 # Subtract 13 from the register, then jump to function 8
1x5f                       # Function 5
    3x7v6l                 # Jump to function 6 if the register is less than variable 7
          8f               # Otherwise, jump to function 8
1x6f                       # Function 6
    3x6v4g                 # Jump to function 4 if the register is greater than variable 6
          9a4a             # Otherwise, add 13 to the register,
              8f           # then jump to function 8
1x7f                       # Function 7
    0a                     # Add 0 to the register
1x8f                       # Function 8
    1o1f                   # Output, then jump to function 1
1f                         # Call function 1

GNU AWK, 147 8+82 = 90 bytes
-lordchr argument
BEGIN{RS=".|";ORS=e}$0=RT~/[A-Za-z]/?chr(ord(RT)+(ord(tolower(RT))>109?-13:13)):RT

Try it online!
After some thought, I realized it is possible to explore GNU AWK's ordchr extension to return the ASCII value of a character, saving tons of bytes. The ROT13 algorithm identifies if the letter is in the first or second half of the alphabet, adding of subtracting 13 to its ASCII value, accordingly.
This code transforms every character as Record Separator, then substitutes every $0 (formerly null) for the matching record separator (RT): ROT13 modified, if it's a letter; or itself, if not.

Ly, 65 bytes
ir[:'@Gf(123)Lf'ZGf'aLfp*!**[p'ZGsp(13)+'Z(32)l*+G[p(26)-0]p0]po]

Try it online!
I'm enjoying learning Ly, so even though this is an old challenge I decided to give it a shot...
This is pretty brute force and the result isn't short compared to other entries.  But it does show how to do things like if-then conditional blocks in Ly, so maybe someone will find it useful?
This bit reads in a line of input as codepoints, reverses the stack, then loops through each character/codepoint.  At the end of the loop the character is printed, rot13'd or not.
ir[                                                            o]

The first thing to do is duplicate the character with : since we need to do two operations and it's easier to make a copy of the character on the stack now and then do the first one.  That first test checks to see if the current character is in "a-z" or "A-Z".  It does that by stacking the results from 4 comparisons, >=A >Z >=a and >z.  Then it combines those 0|1 results mathematically to figure out if we're in the right range.
   :'@Gf(123)Lf'ZGf'aLfp*!**

Then the pattern I've found works for if-then is used to conditionally apply the rot-13 logic only when we get an alphabetic character.  That pattern is ...test...[p...then-code...0]p.  So in this case that's these bits.
                            [p                              0]p

And the code to apply the rotation starts by figuring out and remembering if the character is uppercase or not.  After the s command, the backup cell will be 1|0 to indicated whether or not the character is uppercase.
                              'ZGsp

After that, the code adds 13 to the codepoint, then constructs what the max codepoint value is.  It's either Z or z depending on the case of the original character.  The l command pushed the backup cell (upper/lower flag) onto the stack so we use that to switch the Z to z if necessary.
                                   (13)+'Z(32)l*+

Once that max codepoint is on the stack the code conditionally subtracts 26 if the rotated number it too high.
                                                 G[p(26)-0]p

At that point, the character we want to print is on top of the stack.

Vyxal, 10 bytes
kB½(nn13ǓĿ

Try it Online!
-4 thx to lyxal

Try it Online! for 11 bytes.

@lyxal Thanks, next learn to count!

SM83/Z80, 29 bytes
Input string at (de), output to (hl).

SM83 version

1A 13 47 CB AF D6 41 38
0E FE 1A 30 0A FE 0D 78
38 02 D6 1A C6 0D 47 78
22 B7 20 E4 C9

Z80 version (changes in »German guillemets« except for second bytes of jr for same effective offset¹)

1A 13 47 CB AF D6 41 38
10 FE 1A 30 0C FE 0D 78
38 04 D6 1A C6 0D 47»70
23 04 10«E6 C9

Disassembly and explanation:
rot13:
    ld a,(de)       ; 1A        load character
    inc de          ; 13        increment
    ld b,a          ; 47        save copy
    res 5,a         ; CB AF     clear fifth bit
    sub 65          ; D6 41     subtract 'A'
    jr c,put        ; 38 0E/10  if borrowed, wasn't letter
    cp 26           ; FE 1A     is it 26 or more now?
    jr nc,put       ; 30 0A/0C  if didn't borrow, wasn't letter
    cp 13           ; FE 0D     compare against 13
    ld a,b          ; 78        load original
    jr c,notsub     ; 38 02/04  if carry, was greater than 13
    sub 26          ; D6 1A     subtract 26 if was greater
notsub:
    add 13          ; C6 0D     add 13 either way
    ld b,a          ; 47        store into b
put:                ;           b now contains rot13 version
#ifdef SM83
    ld a,b          ; 78        move into a
    ld (hl+),a      ; 22        store and increment
    or a            ; B7        test if zero
    jr nz,rot13     ; 20 E4     if not, loop
#else
    ld (hl),b       ; 70        store
    inc hl          ; 23        and increment
    inc b           ; 04        if b was 0, it's now 1
    djnz rot13      ; 10 E6     jump back if b is 1 (and decrement)
#endif
    ret             ; C9        return

It's a bit interesting that both CPUs have a way of saving a byte that the other doesn't. The SM83 has autoincrement addressing, while the Z80 has a way to jump if b is 1.
¹ Apparently Z80 relative jump instructions are measured from the start, while SM83's are from the end. (So 18 00 is an infinite loop for Z80 and a three-cycle two-byte no-op for SM83.)

Alice, 129 bytes
vv2++3a-A'<
 a    > Ko= h-A'.<
 #  >@o Ko<>.'Zh-=oK
>wI.=>.'a-h=oK Ko<
 *  >^#va2++3a-a'<
 6    +*   >.'zh-=oK
 >+%'A^>6+%'a+oKo<

Try it online!
Ungolfed
v                      >oK
                 >.'A-h=oK
    >@     >.'Zh-=oK   >'A-a3++2a*6+%'A+oK
                 >oK
>wI.=>.'a-h=oK
                 >'a-a3++2a*6+%'a+oK
    >^     >.'zh-=oK
                 >oK

Python 3, 60 bytes
import this
print("".join(this.d.get(c,c)for c in input()))

K (ngn/k), 40 bytes
`c$@[!256;c@!26;:;(c:"aA"+\:)26!-13+!26]

Try it online!

JavaScript ES6 (155 bytes)
Here is a Caesar cipher that preserves case in in ES6.

// 155 bytes
r=s=>((f,n,m,u,l)=>[...s].map(c=>(x=>x>=u&&x<=u+n?f((x-u+m)%n+u):x>=l&&x<=l+n?f((x-l+m)%n+l):c)(c.charCodeAt())).join(''))(String.fromCharCode,26,13,65,97)

// Begin unit tests
mocha.setup('bdd')
const { expect } = chai
const testCases = [{
  input: "Hello, world!",
  output: "Uryyb, jbeyq!",
}, {
  input: "Code Golf and Coding Challenges is awesome.",
  output: "Pbqr Tbys naq Pbqvat Punyyratrf vf njrfbzr.",
}, {
  input: "Mod abuse!1!!1",
  output: "Zbq nohfr!1!!1",
}]
describe('Caesar cipher (ROT13)', () => {
    it('are all equal', () => {
    for (let { input, output } of testCases) {
      expect(r(input)).to.equal(output)
    }
  })
})
mocha.run()
<link href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.3.4/mocha.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/3.4.1/chai.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.3.4/mocha.js"></script>
<div id="mocha"></div>

Here is one that is 187 bytes (+32 bytes), but no code duplication:
r=s=>((b,f,n,m,u,l)=>[...s].map(c=>(x=>b(u,x,n)?f(u,x,n,m):b(l,x,n)?f(l,x,n,m):c)(c.charCodeAt())).join(''))((v,x,n)=>x>=v&&x<=v+n,(v,x,n,m)=>String.fromCharCode((x-v+m)%n+v),26,13,65,97)

At 192 bytes (+37 bytes), this one is a bit larger, but it builds a lookup and does regex replace:
r=s=>(l=>s.replace(/\w/g,c=>l[c]))(((f,z)=>f(z.map(c=>c.toLowerCase()),f(z,{})))((s,o)=>s.reduce((m,c,i)=>({...m,[c]:s[(i+13)%26]}),o),Array.from({length:26},(_,i)=>String.fromCharCode(i+65))))

Scala 108
def m(a:Int,z:Int,c:Int)=if(c>=a&&c<z)a+((c-a+13)%26)else c
"Ok?".map(c=>print(m(65,91,m(97,123,c)).toChar))

ungolfed:
def m (a: Int, z:Int, c:Int) = if (c >= a && c <= z) a+((c-a+13)%26) else c
"Ok?".foreach (c => print (m ('A', 'Z', m ('a', 'z', c)).toChar))

result:
Bx?

Mathematica 102
StringReplace[Input[],
Join@@Table[Rule@@FromCharacterCode/@{i+c,Mod[i+13,26]+c},{c,{65,97}},{i,0,25}]]

JavaScript 135
s=prompt(),o='',i=0
while((c=s.charCodeAt(i++)))c+=c>64&&c<91?c<52?13:-13:c>96&&c<123?c<109?13:-13:0,o+=String.fromCharCode(c)
alert(o)

Scala (96 chars)
def r(s:String)=s.map{c⇒val m = if(c<91)65 else 97
if(c.isLetter)
((c+13-m)%26+m).toChar
else c}

J, 32 29 bytes
a.{~3&u:+13*2|&.>:'@MZ`mz'&I.

Try it online!

Japt, 28 bytes
c_d)è"%l")?Z|H)<#n?Z+D:Z-D:Z

Try it!
c_d)è"%l")?Z|H)<#n?Z+D:Z-D:Z
c_                                # map input string through a function
  d)è"%l")?                       # regex check if current character is a letter
           Z|H)<#n?               # is it less than the letter n?
                   Z+D:           # if yes, then add 13
                       Z-D:       # otherwise, subtract 13
                           Z      # not a letter, do not transform

20 bytes using replace and switching to v2.0a1. There must be a shorter way, though.

18 bytes

Nice - I had not tried the beta version yet. Looks like regex may have improved?

Yeah, but it's bugged to hell at the moment - only single character class work; anything wrapped in / won't.

17 bytes.

T-SQL, 80 bytes
The TRANSLATE function was introduced in SQL Server 2017.
Input is taken from the column I of the table T.
SELECT TRANSLATE(I,A+B,B+A)FROM(VALUES('ABCDEFGHIJKLM','NOPQRSTUVWXYZ'))V(A,B),T

SQL Fiddle

Zsh, 79 bytes
Builtins only. Try it Online!
for k (${(s::)1})printf ${k/[A-Za-z]/${(#)$((z=#k<91?0:32,65+z+(#k-52-z)%26))}}

Explanation
for k (${(s::)1})  # for each letter $k of the argument $1, loop
&&printf ${..}     # and print the value of expression ${..}, per `man zshexpn`
${k/[A-Za-z]/      # if $k is a letter, replace it with the following stuff,
                   #    otherwise leave it (implicit)
${(#)..}           # convert decimal (in the following expression) to ascii char
$((..))            # math expression
                   #    n.b.: #k is the ascii value (ord) of $k
#k<91?             # ternary: if #k<91, i.e $k is uppercase
65+(#k-52)%26      #    rotate uppercase
:97+(#k-84)%26     #    otherwise, rotate lowercase

Previous solutions: 126, 112, 106, 99, 88, 82
Initial (wrong) solutions: 56, 83b

Google Sheets, 144

Input: A1 (Given named range "A", +1 score)
Column B: =ArrayFormula(CODE(MID(A,SEQUENCE(LEN(A)),1, given named range "B", +1 score
Final output: =ArrayFormula(JOIN(,IF(B=0,,CHAR(IF((B>64)*(B<91),B+13*-1^(B>77),IF((B<97)+(B>122),B,B+13*-1^(B>109

Haskell, 77 bytes
r(a:b:c)=[a..b]++r c
main=interact$map$(r"\0@NZAM[`nzam{\1114111"!!).fromEnum

Try it online!

Stax, 2 bytes
:3

Run and debug it
:3

Assembly (MIPS, SPIM), 122 bytes
main:li$2 12
syscall
abs$4 $2
and$2 95
sub$2'A'
bgtu$2 25p
sub$4 13
bge$2 13p
add$4 26
p:li$2 11
syscall
bne$4 10main
j$ra

Try it online!
Input is a single line from stdin, output is printed to stdout.
Pretty similar to the other ASM versions as that is the best way on baremetal.
main:
.Lloop:
    li    $v0, 12            # READ CHARACTER
    syscall                  # v0 = getchar() or '\n'
    abs    $a0, $v0          # Save copy to a0 (abs is shorter than move for positive)
    and    $v0, 0x5F         # Clear bit 6 to convert lowercase to uppercase
    sub    $v0, 'A'          # Try to convert to number.
    bgtu   $v0, 25, .Lprint  # Non-letters will be < 0 or > 25, test with unsigned > 25
    sub    $a0, 13           # Subtract 13 to rotate left
    bge    $v0, 13, .Lprint  # If the letter-to-number was < 13...
    add    $a0, 26           # Add 26 to revert the left rotation and rotate right
.Lprint:
    li     $v0, 11           # 11 = PRINT CHARACTER
    syscall                  # putchar(a0)
    bne    $a0, '\n', .Lloop # Loop if not end of line
    j      $ra               # Return from main

Thunno, \$ 2 \log_{256}(96) \approx \$ 1.65 bytes
ZY

Attempt This Online!
Builtins FTW!

Thunno 2, 1 byte
V

Attempt This Online!
Built-in solution.
Thunno 2, 12 bytes
kĠD½13ȷẒJsdṆ

Attempt This Online!
Thunno 2 J, 20 bytes
ıÐA?Ä12+26%97+Csfh?R

Attempt This Online!
Non built-in solutions.
Explanations
kĠD½13ȷẒJsdṆ  # Implicit input
kĠD           # Push the string [A-Za-z] and duplicate
   ½          # Halve it to yield [[A-Z], [a-z]]
      ȷ       # To each string in the pair:
    13 Ẓ      #  Rotate it 13 places to the right
              # (We now have [[N-ZA-M], [n-za-m]])
        J     # Join it into [N-ZA-Mn-za-m]
         sd   # Swap and cast to a list of characters
           Ṇ  # Transliterate the input string
              # Implicit output

ıÐA?Ä12+26%97+Csfh?R  # Implicit input
ı                     # Map over the input string:
 Ð                    #  Triplicate the current character
  A                   #  Pop one copy and check if it's alphabetic
   ?                  #  If it is:
    Ä                 #   Pop another copy and push its 1-based index in the alphabet
     12+              #   Add 12 to this number
        26%           #   Mod this number by 26
           97+        #   Add 97 to this number
              C       #   And convert it to a character
               s      #   Swap so the loop character is back on top
                fh    #   Pop it and check if it's uppercase
                  ?   #   If it is:
                   R  #    Uppercase the character on the top of the stack
                      #   Otherwise, the lowercase character stays on top
                      #  Otherwise, the loop character stays on top
                      # Implicit output, joined

Python + Rot13, 23 Bytes
from Rot13 import*
func

There is a package dedicated to this, but looking at the source code of the package, it is not well written...

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

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


text:
Hamming numbers
Hamming numbers are numbers which evenly divide a power of 60. Equivalently, their prime factors are all \$ \le 5 \$.
Given a positive integer, print that many Hamming numbers, in order.
Rules:

Input will be a positive integer \$n \le 1,000,000 \$
Output should be the first \$n\$ terms of https://oeis.org/A051037
Execution time must be \$<1\$ minute
This is code-golf; shortest code wins

Which aim an answer should have? Golf? Most effective algorithm? Just searching of solution methods?

Sorry for not being specific. I haven't solved this myself, so I'm not sure if the bounds I put in are reasonable. Please let me know.

OEIS

1 is a Hamming number, so, printing 1,000,000 1s is conformant with your specs. It will also be in order, i.e. not an unordered sequence. :)

Please add the definition of a Hamming number to your question.

I tried finding out what the 10^6th Hamming number: J B's Haskell post andfR0DDY's Python post showed different values.

Haskell, 101 97 92+|n| characters
h=1:m 2h&m 3h&m 5h
m=map.(*)
c@(a:b)&o@(m:n)|a<m=a:b&o|a>m=m:c&n|0<1=a:b&n
main=print$take 1000000h

Computes the full million in 3.7s on the machine I tested on (variably more if you actually want the output stored)
Ungolfed:
-- print out the first million Hamming numbers
main = print $ take 1000000 h

-- h is the entire Hamming sequence.
-- It starts with 1; for each number in the
-- sequence, 2n, 3n and 5n are also in.
h = 1 : (m 2 h) & (m 3 h) & (m 5 h)

-- helper: m scales a list by a constant factor
m f xs = map (f*) xs

-- helper: (&) merges two ordered sequences
a@(ha:ta) & b@(hb:tb)
    |    ha < hb = ha : ta & b
    |    ha > hb = hb :  a & tb
    |  otherwise = ha : ta & tb

All Haskell is notoriously good at: defining a list as a lazy function of itself, in a way that actually works.

You don't get the positive integer parameter, that add more size to your code

@Zhen The positive integer parameter is the second-to-last token, and its size is declared outfront in the header.

Python 181 Characters
h=[]
h.append(1)
n=input()
i=j=k=0
while n:
    print h[-1]
    while h[i]*2<=h[-1]:
        i+=1
    while h[j]*3<=h[-1]:
        j+=1
    while h[k]*5<=h[-1]:
        k+=1
    h.append(min(h[i]*2,h[j]*3,h[k]*5))
    n-=1

How is this 181 chars? I've saved this to a file, removing the whitespace after h=[], using a minimum tab distance, and single character line breaks, and the file size ends up being 187 bytes.

Anyway... Trivial optimization: h=[1]. Also, give a number directly in the source code, to save characters for numbers <1000000.

And oops, sorry, didn't realize the answer is super-old.

@nitro2k01, I make it 183 chars. (There's some trailing whitespace at the end of the first line, and the indentation should be a space for one level and a tab for two levels).

APL (Dyalog Classic), 34 23 bytes
{⍺⍴{⍵[⍋⍵]}∪,⍵∘.×⍳5}⍣≡∘1

Try it online!
TIO throws a WS FULL error for \$n = 1000000\$, but Dyalog on my laptop runs in about 45 seconds, not counting the scrolling to display numbers.
{⍺⍴{⍵[⍋⍵]}∪,⍵∘.×⍳5}⍣≡∘1     Monadic function:
{⍺⍴{⍵[⍋⍵]}∪,⍵∘.×⍳5}         Define the following helper function g(⍺,⍵):
             ⍵∘.×⍳5             Make a multiplication table between ⍵ and (1 2 3 4 5).
                                (Including 4 is unnecessary but saves bytes.)
            ,                   Flatten the table into an array.
           ∪                    Keep unique elements.
    {⍵[⍋⍵]}                     Grade up the array and access it at those indices.
                                (This is the APL idiom to sort an array.)
 ⍺⍴                             Keep the first ⍺ elements; pad by repeating the array.
{⍺⍴{⍵[⍋⍵]}∪,⍵∘.×⍳5}⍣≡       Repeatedly apply g with some fixed left argument
                             until a fixed point is reached.
                             At this point we have a dyadic function that takes
                             n on the left and the starting value on the right,
                             and returns multiples of the n Hamming numbers.
                      ∘1     Fix 1 as the right argument.

Shuffling things around saves four: 1↓0 1{⍺↑{⍵[⍋⍵]}∪,⍵∘.×⍳5}⍣≡⍨1+⊢

FYI, {⍺⍴∧∪,⍵×⍀⍳5}\⍣≡∘1` in Extended. (Backtick needed due to bug.)

Vyxal j, 8 bytes
λdǏG7<;ȯ

Try it Online!
λ     ;ȯ # First n numbers where
 dǏG     # Maximum of prime factors
    7<   # Less than 7

Vyxal, 29 26 bytes, times out when n>=200,000 on online interpreter.
My first ever Vyxal post.
29->26, adviced by @lyxal.
6ɽ{:L?<|:2*$:3*$:5*∪∪∪}s?Ẏ

How it works
# let first hamming numbers are 1 to 6
6ɽ
# while items of they are less than n; do
{:L?<|
# for each item, multiply with those numbers
# and then unify them; done
  :2*$:3*$:5*∪∪∪}
# sort
s
# take first n items
?Ẏ

Try it Online!

Ruby - 154 231 characters
def k i,n;(l=Math).log(i,2)*l.log(i,3)*l.log(i,5)/6>n end
def l i,n;k(i,n)?[i]:[i]+l(5*i,n)end
def j i,n;k(i,n)?[i]:[i]+j(3*i,n)+l(5*i,n)end
def h i,n;k(i,n)?[i]:[i]+h(2*i,n)+j(3*i,n)+l(5*i,n)end
puts h(1,n=gets.to_i).sort.first n

And now it's fast enough, there is definitely a lot of golfing that can still happen though.
→ time echo 1000000 | ruby golf-hamming.rb | wc
1000000 1000000 64103205
echo 1000000  0.00s user 0.00s system 0% cpu 0.003 total
ruby golf-hamming.rb  40.39s user 0.81s system 99% cpu 41.229 total
wc  1.58s user 0.05s system 3% cpu 41.228 total

MMIX, 92 bytes (23 instrs)
I'm cheating a bit; instead of printing (which would take a lot of work, this being machine language), I instead pass the numbers to a function passed in!
00000000: fe020004 34000100 e3030000 c1040300  “£¡¥4¡¢¡ẉ¤¡¡Ḋ¥¤¡
00000010: e7030001 da040403 3c040304 1d050403  ḃ¤¡¢ḷ¥¥¤<¥¤¥ø¦¥¤
00000020: feff0006 6204ff05 43fffffd 1d050405  “”¡©b¥”¦C””’ø¦¥¦
00000030: feff0006 6204ff05 43fffffd 31ff0401  “”¡©b¥”¦C””’1”¥¢
00000040: 5bfffff3 e7000001 c1050300 bf040100  [””ṙḃ¡¡¢Ḋ¦¤¡Ḃ¥¢¡
00000050: 5b00ffef f6040002 f8000000           [¡”ṁẇ¥¡£ẏ¡¡¡

smooth5 GET    $2,rJ
        NEG    $0,1,$0      // n = 1 - n
        SETL   $3,0         // i = 0
0H      SET    $4,$3
        INCL   $3,1         // loop: j = i++
        SADD   $4,$4,$3     // j = popcnt(j & ~i)
        SR     $4,$3,$4     // j = i >> j (cheap way of getting out factors of 2)
1H      DIV    $5,$4,3      // lp3: k = j / 3
        GET    $255,rR      // tmp = j % 3
        CSZ    $4,$255,$5   // if(!tmp) j = k
        BZ     $255,1B      // if(!tmp) goto lp3
1H      DIV    $5,$4,5      // lp5: k = j / 5
        GET    $255,rR      // tmp = j % 5
        CSZ    $4,$255,$5   // if(!tmp) j = k
        BZ     $255,1B      // if(!tmp) goto lp3
        CMP    $255,$4,1    // tmp = j <=> 1
        PBNZ   $255,0B      // iflikely(tmp) goto loop
        INCL   $0,1         // n++
        SET    $5,$3
        PUSHGO $4,$1,0      // f(i)
        PBNZ   $0,0B        // iflikely(n) goto loop
        PUT    rJ,$2
        POP    0,0          // return

Jelly, 9 bytes
RḤÆfṀ€<7T

Try it online!
Returns all hamming numbers under n.
How?
RḤÆfṀ€<7T     Main Link. Takes n on the left
        T     Filter by
R             Inclusive range
 Ḥ            Double each
  Æf          Prime factors
     €        For each
    Ṁ         Maximum
      <7      Less than 7

My first serious jelly answer

Unfortunately, 8 bytes doesn't work with the time limit :(

@cairdcoinheringaahing yeah, IO rules suck

Python 3.8 (pre-release), 97 bytes
Inefficient but golfy. Lot's of keywords and whitespace, so potential for more golfing.
def f(n):
 h=[1]
 while(n:=n-1):h+=[min(j*k for j in(2,3,5)for k in h if j*k not in h)]
 return h

Try it online!
Python 3.8 (pre-release), 165 bytes
Slightly golfed version of the original Python entry.
Reposted, because of its age.
def f(n):
 h=[1];i=j=k=0
 while(n:=n-1):
  m=h[-1]
  while(h[i]*2<=m):i+=1
  while(h[j]*3<=m):j+=1
  while(h[k]*5<=m):k+=1
  h+=[min(h[i]*2,h[j]*3,h[k]*5)]
 return h

Try it online!

GAWK -M, 138 120 bytes.
It was originally a post on rosetta code.
Without -M it overflows when huge value is input.
{a=2
b=3
c=5
for(s=h[0]=1;--$0;c-z||c=5*h[++k]){z=a<b?a:b
s=s" "(z=h[++n]=z<c?z:c)
a-z||a=2*h[++i]
b-z||b=3*h[++j]}}$0=s

Try it online!
Usage
Given from stdin, as a line consists of a string of decimal natural number.
Execution time
Tested in my Termux. CPU is:
Architecture:        aarch64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              8
On-line CPU(s) list: 0-7
Thread(s) per core:  1
Core(s) per socket:  4
Socket(s):           2
Vendor ID:           ARM
Model:               4
Model name:          Cortex-A53
Stepping:            r0p4
CPU max MHz:         1768.0000
CPU min MHz:         449.0000
BogoMIPS:            52.00
Flags:               fp asimd evtstrm aes pmull sha1 sha2 crc32

With original code
10^6th Hamming number is 519312780448388736089589843750000000000000000000000000000000000000000000000000000000.
$ time echo 1000000 | awk -Mf Textfile/ham.awk
# lots of output
real    2m36.842s
user    0m25.224s
sys     0m5.356s

If $0=s is removed
$ time echo 1000000 | awk -Mf Textfile/ham.awk
real    0m25.404s
user    0m24.676s
sys     0m0.716s

Note

Original 138 bytes of post outputs incorrectly: it outputs n+1 numbers, not n.

OBTW replacing variables a,b,c,i,j,k with arrays resulted in 132 bytes. Try it online!

@tailsparkrabbitear In the case 130 bytes: Try it online!

JavaScript (ES6), 110 bytes
f=h=>eval("g=n=>n-1n?n%2n?n%3n?n%5n?0:g(n/5n):g(n/3n):g(n/2n):1;r=[i=1n];while(!r[h-1])if(g(++i))r.push(i);r")

Theoretically works for arbitrarily large inputs, but prohibitively slow.

Vyxal 3, 7 bytes
ЧdḟG7<Ẇ

Try it Online!
Port of Emanrasu's Vyxal answer

Ursala, 103
#import std
#import nat
smooth"p" "n" = ~&z take/"n" nleq-< (rep(length "n") ^Ts/~& product*K0/"p") <1>

Output for main = smooth<2,3,5>* nrange(1,20)
<1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36>

Haskell, 71
h n = drop n $ iterate (\(_,(a:t))-> (a,union t [2*a,3*a,5*a])) (0,[1])

Output
*Main> map fst $ take 20 $ h 1
[1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36]

The spec calls for you to print, so the code to print should be counted. This also allows a fair comparison against the other Haskell implementation.

@PeterTaylor How many characters do you think I should add?

source: Stack Exchange

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

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

sort: votes


text:
N-Queens problem
In chess, a queen can move as far as as the board extends horizontally, vertically, or diagonally.
Given a NxN sized chessboard, print out how many possible positions N queens can be placed on the board and not be able to hit each other in 1 move.

Do we need to handle 2 <= N <= 4 cases? If so how?

There is no solution for case: N = 2,3. The wikipedia has a excellent write up about this classic problem. It documents ver well about the solution number from N = 1 to N = 14. (I am still new to Code Golf. Not sure what is the best way to participate yet. :))

A000170

Here's a solution (originally from this blog entry) where I construct a logical description of the solution in conjunctive normal form which is then solved by Mathematica:
(* Define the variables: Q[i,j] indicates whether there is a
   Queen in row i, column j *)
Qs = Array[Q, {8, 8}];

(* Define the logical constraints. *)
problem =
  And[
   (* Each row must have a queen. *)
   And @@ Map[(Or @@ #) &, Qs],
   (* for all i,j: Q[i,j] implies Not[...] *)
   And @@ Flatten[
     Qs /. Q[i_, j_] :>
       And @@ Map[Implies[Q[i, j], Not[#]] &,
         Cases[Qs,
          Q[k_, l_] /;
           Not[(i == k) && (j == l)] && (
             (i == k) ||          (* same row *)
                 (j == l) ||          (* same column *)
             (i + j == k + l) ||  (* same / diagonal *)
             (i - j == k - l)),   (* same \ diagonal *)
          2]]]];

(* Find the solution *)
solution = FindInstance[problem, Flatten[Qs], Booleans] ;

(* Display the solution *)
Qs /. First[solution] /. {True -> Q, False -> x} // MatrixForm

Here's the output:
x   x   x   x   Q   x   x   x
x   Q   x   x   x   x   x   x
x   x   x   Q   x   x   x   x
x   x   x   x   x   x   Q   x
x   x   Q   x   x   x   x   x
x   x   x   x   x   x   x   Q
x   x   x   x   x   Q   x   x
Q   x   x   x   x   x   x   x

Ruby I don't see a golf tag, so i'm assuming it's just a challenge.
Here's an implementation of the Algorithm mentioned on Wikipedia. It's not by me, it's at Rosetta Stone and can be found here
CommWikied this Answer.

Python 2, 190 185 chars

from itertools import*
n=input()
print len(filter(lambda x:all(1^(y in(z,z+i-j,z-i+j))for i,y in enumerate(x)for j,z in enumerate(x[:i]+(1e9,)+x[i+1:])),permutations(range(1,n+1),n)))

I just assumed the code golf tag even though it wasn't there. N is read from stdin, the program calculates solutions up to n=10 in acceptable time.

Groovy
n=8
s=(1..n).permutations().findAll{
  def x=0,y=0
  Set a=it.collect{it-x++}
  Set b=it.collect{it+y++}
  a.size()==it.size()&&b.size()==it.size()
}

Delivers a list of all queen solutions like this:
[ [4, 7, 3, 0, 6, 1, 5, 2],
  [6, 2, 7, 1, 4, 0, 5, 3],
  ... ]

For graphical representation add:
s.each { def size = it.size()
         it.each { (it-1).times { print "|_" }
                   print "|Q"
                   (size-it).times { print "|_" }
                   println "|"
                 }
         println ""
         }

which looks like this:
|_|Q|_|_|_|_|_|_|
|_|_|_|Q|_|_|_|_|
|_|_|_|_|_|Q|_|_|
|_|_|_|_|_|_|_|Q|
|_|_|Q|_|_|_|_|_|
|Q|_|_|_|_|_|_|_|
|_|_|_|_|_|_|Q|_|
|_|_|_|_|Q|_|_|_|

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


text:
Rand5() to Rand7()
You are provided with a function Rand5(). This function returns perfectly random (equal distribution) integers between 1 and 5.
Provide the function Rand7(), which uses Rand5() to produce perfectly random integers between 1 and 7.

Duplicate question

Obligatory xkcd: http://xkcd.com/221/

1 and 5 inclusive? i.e. from the set {1,2,3,4,5} ?

What criteria determines a single winner?

That moment when you realize this is actually an old question.

@nyuszika7h That moment when a question is put on hold after nearly 4 years and the OP hasn't been on PPCG since May. :P

Java - 61 chars
int rand7(){int s=0,c=7;while(c-->0)s+=rand5();return s%7+1;}

Test driver for validation:
class Rand {

    public static void main(String[] args) {
        int[] nums = new int[7];
        // get a lot of numbers
        for(int i = 0; i < 10000000; i++) nums[rand7()-1]++;
        // print the results
        for(int i = 0; i < 7; i++) System.out.println((i+1) + ": " + nums[i]);
    }

    // just for rand5()
    static java.util.Random r = new java.util.Random();

    static int rand5() {
        return r.nextInt(5)+1; // Random.nextInt(n) returns 0..n-1, so add 1
    }

    static int rand7(){int s=0,c=7;while(c-->0)s+=rand5();return s%7+1;}

}

Results
C:\Documents and Settings\glowcoder\My Documents>java Rand
1: 1429828
2: 1429347
3: 1428328
4: 1426486
5: 1426784
6: 1429853
7: 1429374

C:\Documents and Settings\glowcoder\My Documents>

Extra points for the "goes to operator"

shave a char?  int rand7(){for(int s=0,c=7;c-->0;s+=rand5());return s%7+1;}

This answer is not correct: the probabilities of this function returning the values from 1 to 7 are 0.1430656, 0.1430016, 0.1428224, 0.1426432, 0.1426432, 0.1428224 and 0.1430016 respectively. Yes, the difference between the minimum and maximum probabilities is less that 0.0005, but still, the question specified "perfectly random integers".

@ilmari You're right - I just ran a test and it seems the distribution isn't even... let me think on that...

@IlmariKaronen: I guess I know the solution. :)

@glowcoder: Since @Ilmari does not respond any more: I guess he forgot to use a perfectly random Rand5 () as input, and therefore earned not perfect Rand7 as output.

@userunknown That's not the case. The case is that the addition used is less likely to wind up in the middle than the edge cases. This is evidenced by my output too, but it's very subtle!

@userunknown: Yes, the probabilities I posted are actually not approximations, they exact (0.1430656 = 11177 / 78125, etc.) assuming a perfectly random rand5. I computed them in Maple using simple matrix algebra, but you can do it with pencil and paper in a few minutes if you want. Anyway, it turns out Omar already posted the same figures (sans normalizing factor) in a comment to another answer a couple of days earlier. (Also ps., you can only @notify one user per comment, although the post's author is notified always in any case.)

Perl - 47 (was 52) chars
sub rand7{($x=5*&rand5+&rand5-3)<24?int($x/3):&rand7}

Plus I get to use the ternary operator AND recursion. Best... day... ever!
OK, 47 chars if you use mod instead of div:
sub rand7{($x=5*&rand5+&rand5)<27?$x%7+1:&rand7}

So close... replace the 30 with 27 (= 6 + 21) and you'll get a perfectly uniform distribution.  Oh, and you can drop the last two & signs to get it down to 46 chars (including the space, which puts your current version at 48).

In Python:
def Rand7():
  while True:
    x = (Rand5() - 1) * 5 + (Rand5() - 1)
    if x < 21: return x/3 + 1

in Python 3.X, use return x//3 + 1

JavaScript, 42
Rand7=f=_=>(x=Rand5()+Rand5()*5-5)>7?f():x

Bonus ES5 thing:
Rand7=eval.bind(0,'for(;x=Rand5()+Rand5()*5-5,x>7;);x')

Ruby - 54 chars (based on Dan McGrath solution, using loop)
def rand7;x=8;while x>7 do x=rand5+5*rand5-5 end;x;end

Ruby - 45 chars (same solution, using recursion)
def rand7;x=rand5+5*rand5-5;x>7 ?rand7: x;end

Can be shortened by 1 char by using (x=rand5+5*rand5-5)>7?.

In Common Lisp 70 characters:
(defun rand7()(let((n(-(+(rand5)(* 5(rand5)))5)))(if(> n 7)(rand7)n)))

The parenthesis take up more space than I would like.

Nice.  You can squeeze out two more characters by making n a global variable: (defun rand7()(setq n(-(+(rand5)(* 5(rand5)))5))(if(> n 7)(rand7)n))

Even better: (defun rand7()(if(>(setq n(-(+(rand5)(* 5(rand5)))5))7)(rand7)n))

In c/c++ using rejection sampling
int rand7(){int x=8;while(x>7)x=rand5()+5*rand5()-5;return x;}

62 characters.

@barrycarter: The condition is while(x>7), so that would only be satisfied by numbers in the valid range.

My bad. Deleted my dumb comment.

@barry And then you left another one. ;)

It took me a few minutes to realize how the math here produces a uniformly random distribution which can be used for rejection sampling.

Translation to PHP, from the answer posted ny Dan McGrath.
function Rand7(){$x=8;while($x>7)$x=rand5()+5*rand5()-5;return $x;}

67 characters.

Shouldn't this be prefixed by the word "function" (and a space)?

Yeah... and now it's 67 characters...

R, 34 characters
In R (a language built for statistical computation), a deliberately cheaterish solution:
# Construct a Rand5 function
Rand5 <- function() sample(seq(5),1)
# And the golf
Rand7=function(r=Rand5())sample(1:(r/r+6),1)
# Or (same character count)
Rand7=function(r=Rand5())sample.int(r/r+6,1)
# Or even shorter(thanks to @Spacedman)
Rand7=function()sample(7)[Rand5()]

Thanks to lazy evaluation of arguments, I eliminated the semicolon and braces.
Output over 10^6 replicates:
> test <- replicate(10^6,Rand7())
> table(test)
test
     1      2      3      4      5      6      7
142987 142547 143133 142719 142897 142869 142848

library(ggplot2)
qplot(test)

If you're going to be cheaterish, you may as well be the best cheater you can be: Rand7=function(){r=Rand5();sample(7)[r]}

If you are going to do that, why bother with the intermediate storage? Rand7=function(){sample(7)[Rand5()]}

@BrianDiggs Path-dependency in action.... :-)

In Java (or C/C++ I suppose)

using generation formula by Alexandru, in 65 characters:
int rand7(){int x=rand5()*5+rand5()-6;return x>20?rand7():x/3+1;}

using generation formula by Dan McGrath, in 60 characters
int rand7(){int x=rand5()+5*rand5()-5;return x>7?rand7():x;}

C++
int Rand4()
{
    int r = Rand5();
    return r > 4 ? Rand4() : r;
}

inline int Rand8()
{
    return (Rand4() - 1) << 2 + Rand4();
}

int Rand7()
{
    int r = Rand8();
    return r > 7 ? Rand7() : r;
}

C++ (109)
Golfed
int Rand4(){int r=Rand5();return r>4?Rand4():r;}int Rand7(){int r=Rand4()-1<<2+Rand4();return r>7?Rand7():r;}

I don't really think you can call that a "one liner" because semicolons define a line of code in C++.

@Peter Oh well, it doesn't even require one-liners anymore.

It returned a number from 1 to 8.

scala,  47, 40 59 chars:
def rand7:Int={val r=5*(rand5-1)+rand5
if(r<8)r else rand7}

with 2 inputs from rand5:
\ 1 2 3 4 5
1 1 2 3 4 5
2 6 7 8 ..
3 11 ..
4 ..
5

I multiply the first-1 by 5, and add the second. Most results are ignored, and lead to a new calculation. The result should be an equal distribution of values from 1-25, from which I only pick the first 7 ones. I could accept the first 21 with building a modulo, but this would lead to longer code.
historic code which failed, but not very obviously. Thanks to Ilmari Karonen for pointing it out:

def rand7=(1 to 7).map(_=>rand5).sum%7+1

Thanks to Yoshiteru Takeshita, for this scala-2.8.0-approach which made 'sum' so easy. My solution before:
def rand7=((0/:(1 to 7))((a,_)=>a+rand5-1))%7+1

rand5:
val rnd = util.Random
def rand5 = rnd.nextInt (5) + 1

User Yoshiteru Takeshita proposed a reduction to 40 chars for Scala 2.8.0 or later as def rand7=(1 to 7).map(_=>rand5).sum%7+1

This solution is also not correct, see the comments to glowcoder's answer.

@IlmariKaronen: You're right - I reworked my solution.

С++
int Rand7()
{
    int r = Rand5();
    int n = 5;
    do {
        r = (r - 1) * 5 + Rand5();
        int m = n * 5 / 7 * 7;
        if (r <= m) {
            return r % 7 + 1;
        }
        r -= m;
        n = n * 5 - m;
    } while (1);
}

Numbers distribution (1000000 integers):
142935 142751 142652 143299 142969 142691 142703

Average number of calls to Rand5() per every generated integer is about 2.2 (2 to 10+).
1 2      3      4     5    6   7 8  9 10
0 840180 112222 44433 2212 886 0 60 6 1

Translation to Javascript, from the answer posted by Dan McGrath.
function Rand7(){x=8;while(x>7)x=rand5()+5*rand5()-5;return x}

62 chars

function Rand7(){for(x=8;x>7;x=rand5()+5*rand5()-5);return x} is little shorter :P

Python, 56 37 chars
Another solution that may be wrong, in Python:
rand7 = lambda: sum(rand5() for i in range(7)) % 7 + 1

This seems to be too simple, but when I try:
counter = [0] * 7
for i in range(100000):
     counter[rand7()] += 1

I get a reasonably even distribution (all between 14000 and 14500).
Okay, now as somebody voted for this post: Is this solution indeed correct? I more posted this here to make people criticize it. Well, if it is correct, my golfed version would be:
rand7=lambda:eval("+rand5()"*7)%7+1

which comes out to 37 chars.

Your solution is not correct: you base your decision on 7 rolls of a fair 5-sided die, which means there are 5^7 (5 to the 7th power) equiprobable outcomes. Since this is not a multiple of 7, you cannot return 7 equiprobable results. I don't think there's an easy formula for what you return; you can brute-force the computation or work it out by hand on smaller numbers (flip 3 coins (H=1, T=2) and sum the results).

Wow, the distribution you generate, though not uniform, is remarkably close: the exact proportion of the probabilities of each number is {1: 11177, 2: 11172, 3: 11158, 4: 11144, 5: 11144, 6: 11158, 7: 11172}

JavaScript, 85
function Rand7(){for(x=0,i=1;i<8;x^=i*((k=Rand5())%2),i*=1+(k<5));return x?x:Rand7()}

I know there's shorter answer, but I wanted to show the test of this puzzle. It turns out that only Clyde Lobo's answer using Dan McGrath's rejection sampling is correct (between JS answers).

Java, 65 chars:
int rand7(){int r;do{r=rand5()+5*rand5()-5;}while(r>7);return r;}

Java - 66 chars
int rand7(){int s;while((s=rand5()*5+rand5())<10);return(s%7+1);}

Longer than previous routine, but I think this one returns uniformly distributed numbers in less time.

Clojure - 58 chars
(defn rand7[](#(if(<% 8)%(rand7))(+(rand5)(*(rand5)5)-5)))

Python, 70 chars
def rand7():
 while True:
  n=5*(rand5()-1)+(rand5()-1)
  if n<21:return n%7+1

but completely correct based on the reasoning here.

Perl, 43 chars, iterative rejection sampling
sub rand7{1while($_=5*&rand5-rand5)>6;$_+1}

This gives a warning about Ambiguous use of -rand5 resolved as -&rand5(), but works correctly.  Prepending an & also to the second rand5 call fixes it at the cost of one stroke.  (Conversely, the other & can also be removed if rand5 has been defined with a () prototype.)
Ps. The following 46-char version is about three times faster:
sub rand7{1while($_=5*&rand5-rand5)>20;$_%7+1}

PostScript (46)
This uses binary token encoding, therefore, here is a hexdump:
00000000  2f 72 61 6e 64 37 7b 38  7b 92 38 37 92 61 7b 92  |/rand7{8{.87.a{.|
00000010  40 7d 69 66 92 75 32 7b  72 61 6e 64 35 7d 92 83  |@}if.u2{rand5}..|
00000020  35 92 6c 92 01 35 92 a9  7d 92 65 7d 92 33        |5.l..5..}.e}.3|
0000002e

To try it out, you can also download it.
Here is the ungolfed and commented code, together with testing code.
% This is the actual rand7 procedure.
/rand7{
  8{                      % potentialResult
    % only if the random number is less than or equal to 7, we're done
    dup 7 le{             % result
      exit                % result
    }if                   % potentialResult
    pop                   % -/-
    2{rand5}repeat        % randomNumber1 randomNumber2
    5 mul add 5 sub       % randomNumber1 + 5*randomNumber2 - 5 = potentialResult
  }loop
}def

%Now, some testing code.

% For testing, we use the built-in rand operator;
% Doesn't really give a 100% even distribution as it returns numbers
% from 0 to 2^31-1, which is of course not divisible by 5.
/rand5 {
  rand 5 mod 1 add
}def

% For testing, we initialize a dict that counts the number of times any number
% has been returned. Of course, we start the count at 0 for every number.
<<1 1 7{0}for>>begin

% Now we're calling the function quite a number of times
% and increment the counters accordingly.
1000000 {
  rand7 dup load 1 add def
}repeat

% Print the results
currentdict{
  2 array astore ==
}forall

int result = 0;

for (int i = 0; i++; i<7)
    if (((rand(5) + rand(5)) % 2) //check if odd
        result += 1;

return result + 1;

This won't give a uniform distribution. Look at the distribution of rand(5)+rand(5) over 10000 iterations to see why

result can be any number from 1 to 8 in your code...

Plus, as gnibbler said, the distribution is not uniform: (rand(5)+rand(5))%2 is biased towards 0, it produces 0 13 times for every 12 times it produces 1; i.e., the probabilities are proportional to {0: 13, 1: 12}. With that notation, the probalities for your function are proportional to {1: 62748517, 2 : 405451956, 3: 1122790032, 4: 1727369280, 5: 1594494720, 6: 883104768, 7: 271724544, 8: 35831808} (quite heavily skewed towards larger numbers). Or, fixing the loop to run 6 times, {1: 4826809, 2: 26733096, 3: 61691760, 4: 75928320, 5: 52565760, 6: 19408896, 7: 2985984}

Groovy
rand7={if(b==null)b=rand5();(b=(rand5()+b)%7+1)}

example distribution over 35,000 iterations:
[1:5030, 2:4909, 3:5017, 4:4942, 5:5118, 6:4956, 7:5028]

Is it bad that it's stateful?

Mathematica, 30
Rand7=Rand5[]~Sum~{7}~Mod~7+1&

R (30 characters)
Define rand7:
rand7=function(n)sample(7,n,T)

Because R was written with statistical analysis in mind, this task is trivial, and I use the built-in function sample with replacement set to TRUE.
Sample output:
> rand7(20)
 [1] 4 3 6 1 2 4 3 2 3 2 5 1 4 6 4 2 4 6 6 1
> rand7(20)
 [1] 1 2 5 2 6 4 6 1 7 1 1 3 7 6 4 7 4 2 1 2
> rand7(20)
 [1] 6 7 1 3 3 1 5 4 3 4 2 1 5 4 4 4 7 7 1 5

It does say you have to use Rand5. Doesn't say how, but you have to use it...

@Spacedman Yes, I explicitly ignored it. That is use by non-reference.

How about this?
int Rand7()
{
    return Rand5()+ Rand5()/2;
}

Whatever language that is, does its / operator do integer math? What happens to your results if it does decimal, floating-point, or integer math?

Assuming integer division, this function has the following distribution: [2/25, 4/25, 5/25, 5/25, 5/25, 3/25, 1/25]. Not exactly uniform.

primo is right. adding random numbers is generally going to skew the probabilities toward the middle values.

Ruby (43 bytes)
def rand7;(0..7).reduce{|i|i+rand5}%7+1;end

cemper93's solution ported to Ruby is three bytes shorter ;) (34 bytes)
def rand7;eval("+rand5"*7)%7+1;end

Java - 54
int m=0;int rand7(){return(m=m*5&-1>>>1|rand5())%7+1;}

Distribution test:
[1000915, 999689, 999169, 998227, 1001653, 1000419, 999928]
Algorithm:

Keep a global variable
multiply by 5, so there get 5 places free at the least significant end
Truncate the sign bit to make it positive (not necessary if unsigned numbers were supported)
Modulo 7 is the answer

> The numbers are not mutually uncorrelated anymore, but individually perfectly random.

C/C++ code the core code has one line only!
static unsigned int gi = 0;

int rand7()
{
    return (((rand() % 5 + 1) + (gi++ % 7)) % 7) + 1;
}

//call this seed before rand7
//maybe it's not best seed, if yo have any good idea tell me please
//and thanks JiminP again, he remind me to do this
void srand7()
{
    int i, n = time(0);
    for (i = 0; i < n % 7; i++)
        rand7();
}

The srand7() is the seed of rand7, must call this function before rand7, just like call srand before rand in C.
This is a very good one, because it call rand() only one time, and no loop thing, no expends extra memories.
Let me explain it: consider a integer array with size of 5:
1st get one number from 1 2 3 4 5 by rand5
2nd get one number from 2 3 4 5 6
3rd get one number from 3 4 5 6 7
4th get one number from 4 5 6 7 1
5th get one number from 5 6 7 1 2
5th get one number from 6 7 1 2 3
7th get one number from 7 1 2 3 4

So we got the TABLE, each one of 1-7 appears 5 times in it, and has all 35 numbers, so the probability of each number is 5/35=1/7. And next time,
8th get one number from 1 2 3 4 5
9th get one number from 2 3 4 5 6
......

After enough times, we can get the uniform distribution of 1-7.
So, we can allocate a array to restore the five elements of 1-7 by loop-left-shift, and get one number from array each time by rand5. Instead, we can generate the all seven arrays before, and using them circularly. The code is simple also, has many short codes can do this.
But, we can using the properties of % operation, so the table 1-7 rows is equivalent with (rand5 + i) % 7, that is :
a = rand() % 5 + 1 is rand5 in C language,
b = gi++ % 7 generates all permutations in table above, and 0 - 6 replace 1 - 7
c = (a + b) % 7 + 1, generates 1 - 7 uniformly.
Finally, we got this code:
(((rand() % 5 + 1) + (gi++ % 7)) % 7) + 1

But, we can not get 6 and 7 at first call, so we need a seed, some like srand for rand in C/C++, to disarrange the permutation for first formal call.
Here is the full code to testing:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

static unsigned int gi = 0;

//a = rand() % 5 + 1 is rand5 in C language,
//b = gi++ % 7 generates all permutations,
//c = (a + b) % 7 + 1, generates 1 - 7 uniformly.
//Dont forget call srand7 before rand7
int rand7()
{
   return (((rand() % 5 + 1) + (gi++ % 7)) % 7) + 1;
}

//call this seed before rand7
//maybe it's not best seed, if yo have any good idea tell me please
//and thanks JiminP again, he remind me to do this
void srand7()
{
    int i, n = time(0);
    for (i = 0; i < n % 7; i++)
        rand7();
}

void main(void)
{
    unsigned int result[10] = {0};
    int k;

    srand((unsigned int)time(0)); //initialize the seed for rand
    srand7() //initialize the rand7

    for (k = 0; k < 100000; k++)
        result[rand7() - 1]++;

    for (k = 0; k < 7; k++)
        printf("%d : %.05f\n", k + 1, (float)result[k]/100000);
}

It 'passes' the 'test', but that doesn't mean this is a good random function. Can I get 6 or 7 by calling it once?

But there's good kinds and bad kinds of approximation. And this code is bad - because it does not gives uniform distribution when called only once. If one wrote something like int main(){if(rand7()==6) printf("Hello, world!");}, approximation using loop will print 'Hello, world!' 1 in 7 times, but your code doesn't.

thank you @JiminP! you are right for 6,7 at first time. i need a seed to disarrange before call rand7, the seed just like the srand in C/C++. i fixed my code, and thank you again!!!

hm....the srand10 does not work, the last 3 numbers can not get at 10, 20, 30 ...positions. sorry @JiminP, but how to modify it? i think this is hopeful way.

Different calls to this function are not independent of each other. The spec here doesn't require this, but that is typically expecetd of random number generators. Otherwise, you could say, return a random uniform number the first time and in future calls  just return (previous+1)%7...

JavaScript (53 characters):
function Rand7(){return Math.abs(Rand5()-3)+Rand5()}

JSFiddle Example: here
Same algorithm on PHP (49 characters):
function Rand7(){return abs(Rand5()-3)+Rand5();}

The resulting distribution is not uniform. For instance the chance of pulling a seven is P(7) = 0.4 * 0.2 = 0.08 != 1/7.