text:
Determining the continued fractions of square roots
The continued fraction of a number \$n\$ is a fraction of the following form:
$$a_0 + \cfrac 1 {a_1 + \cfrac 1 {a_2 + \cfrac 1 {a_3 + \cfrac 1 {a_4 + \ddots}}}}$$
which converges to \$n\$.
The sequence \$a\$ in a continued fraction is typically written as: \$[a_0; a_1, a_2, a_3, ... a_n]\$.
We will write ours in the same fashion, but with the repeating part between semicolons.
Your goal is to return the continued fraction of the square root of \$n\$.
Input: An integer, \$n\$. \$n\$ will never be a perfect square.
Output: The continued fraction of \$\sqrt n\$.
Test Cases:
2 -> [1; 2;]
3 -> [1; 1, 2;]
19 -> [4; 2, 1, 3, 1, 2, 8;]
Shortest code wins. Good luck!

Does the output have to be in the same format as the test cases?

No. As long as you have the semicolons, it's fine.

Hm, getting the right answers, having trouble knowing when the fraction is rational to stop. Is it really as simple as when a0 is double the sqrt of the original input?

Yep, that's the limit.

@beary605 thanks.  Been doing a lot more reading, and now I see that the continued fraction of a square root is a bit of a special case.  Fascinating stuff!  Still working on a non-floating point version.

GolfScript (66 60 chars)
~:^,{.*^>}?(:?';'[1?{^1$.*-@/?@+.2$/@@1$%?\- 1$(}do;;]','*1$

Warning: most of the ? in there are the variable representing floor(sqrt(input)) rather than the builtin. But the first one is the builtin.
Takes input on stdin and outputs to stdout.
Psuedocode of the algorithm (proof of correctness currently left as an exercise for the reader):
n := input()
m := floor(sqrt(n))
output(m)
x := 1
y := m
do
  x := (n - y * y) / x
  output((m + y) / x)
  y := m - (m + y) % x
while (x > 1)

Yet again I find myself wanting a single operator which takes a b on the stack and leaves a/b a%b on the stack.

I'd say that I really need to learn GS... but need is a bit too strong a word here ;)

@boothby, don't be crazy. Your life won't be complete without GS ;)

Python, 95 97 (but correct...)
This uses only integer arithmetic and floor division.  This will produce correct results for all positive integer inputs, though if one wants to use a long, they'd have to add a character; for example m=a=0L.  And of course... wait for a million years for my poor man's floor sqrt to terminate.
z=x=m=1
while n>m*m:m+=1
m=y=m-1
l=()
while-z<x:x=(n-y*y)/x;y+=m;l+=y/x,;y=m-y%x;z=-1
print c,l

Output:
n=139
11 (1, 3, 1, 3, 7, 1, 1, 2, 11, 2, 1, 1, 7, 3, 1, 3, 1, 22)

edit: now using Peter Taylor's algorithm.  That do...while was fun.

What is the purpose of *(c*c-n)?

@PeterTaylor, I hadn't read the challenge carefully enough, and made the code work for perfect squares.

Python, 87 82 80
x=r=input()**.5
while x<=r:print"%d"%x+",;"[x==r],;x=1/(x%1)
print`int(r)*2`+";"

It takes one integer and gives output like:
4; 2, 1, 3, 1, 2, 8;

x-int(x) -> x%1. I am impressed :)

Gives the wrong result for √139 according to Wolfram Alpha

I've updated it to work for √139. However, if the length of the sequence gets much longer (√139 has a sequence of 18 numbers), then the result will probably start to lose accuracy.

I find it incredibly interesting that it always ends in 2*int(sqrt(a)).

Further interesting is now 3 of us have broken code for 139 (mine is still un-golfed and un-posted).

@JoeFish, It's not a surprise.  The question involves computing an exact quantity.  Floating point arithmetic will almost never suffice.

Mathematica 33  31
c[n_]:=ContinuedFraction@Sqrt@n

Output is in list format, which is more appropriate for Mathematica.
Examples:
c[2]
c[3]
c[19]
c[139]
c[1999]

(* out *)
{1, {2}}
{1, {1, 2}}
{4, {2, 1, 3, 1, 2, 8}}
{11, {1, 3, 1, 3, 7, 1, 1, 2, 11, 2, 1, 1, 7, 3, 1, 3, 1, 22}}
{44, {1, 2, 2, 4, 1, 1, 5, 1, 5, 8, 1, 3, 2, 1, 2, 1, 1, 1, 1, 1, 1,
  1, 14, 3, 1, 1, 29, 4, 4, 2, 5, 1, 1, 17, 2, 1, 12, 9, 1, 5, 1, 43,
  1, 5, 1, 9, 12, 1, 2, 17, 1, 1, 5, 2, 4, 4, 29, 1, 1, 3, 14, 1, 1,
  1, 1, 1, 1, 1, 2, 1, 2, 3, 1, 8, 5, 1, 5, 1, 1, 4, 2, 2, 1, 88}}

Oh man, I totally expected this answer. I won't consider it as an actual answer, unless you generate the continued fraction yourself.

@beary605 Fair enough.

+1 Better yet (25 chars) ContinuedFraction@Sqrt@#&

What exactly are you counting here? Is this a program which takes input from stdin? Because the way you use it looks like it's a function body without the function definition.

@Peter Taylor Please see the amendment.

@DavidCarraher sorry, hadn't read the comments following the question; thought output was strict.

@belisarius I (finally) followed your suggestion for shortening the code. Thanks.

@David You've more votes than the accepted answer. That tells the tale :)

@belisarius I'm not sure what the tale is but it is interesting nonetheless.

Python (136 133 96)
The standard method for continued fractions, extremely golfed.
a=input()**.5
D=c=int(a);b=[]
while c!=D*2:a=1/(a%1);c=int(a);b+=[c]
print D,";%s;"%str(b)[1:-1]

You can save a few chars by using while 1:. You could also put most of the statements in the while loop on a single line.

When I run your script, I get an output of 8 ;1; for 74 and for 75; that doesn't seem right. It hangs on 76.

^^ Yep. Fixed my code.

This version gives the wrong result for 139.

@boothby Then I'll delete mine and we'll call it a draw :)

Perl, 99 chars
Does not screw up on 139, 151, etc. Tested with number ranging from 1 to 9 digits.
$"=",";$%=1;$==$-=($n=<>)**.5;
push@f,$==(($s=$=*$%-$s)+$-)/($%=($n-$s*$s)/$%)until$=>$-;
say"$-;@f;"

Note: $%, $=, and $- are all integer-forcing variables.

C, 137
Including the newline, assuming I don't have to roll my own square root.
#include<math.h>
main(i,e){double d;scanf("%lf",&d);e=i=d=sqrt(d);while(i^e*2)printf("%d%c",i,e^i?44:59),i=d=1.0/(d-i);printf("%d;",i);}

It breaks for sqrt(139) and contains the occasional extra semicolon in the output, but I'm too tired to work on it further tonight :)

5
2;4;
19
4;2,1,3,1,2,8;
111
10;1,1,6,1,1,20;

APL(NARS), 111 chars, 222 bytes
r←f w;A;a;P;Q;m
m←⎕ct⋄Q←1⋄⎕ct←P←0⋄r←,a←A←⌊√w⋄→Z×⍳w=0
L: →Z×⍳0=Q←Q÷⍨w-P×P←P-⍨a×Q⋄r←r,a←⌊Q÷⍨A+P⋄→L×⍳Q>1
Z: ⎕ct←m

The f function is based on the algo one find in the page http://mathworld.wolfram.com/PellEquation.html
for solve Pell equation. That f function has its  input all not negative number (type fraction too).
Possible there is something goes wrong, I remember that √ has, in how I see it, problem for big fraction numbers, as
  √13999999999999999999999999999999999999999999999x
1.183215957E23

so there would be one function sqrti(). For this reason fraction input (and integer input) has to be <10^15.
test:
 ⎕fmt (0..8),¨⊂¨f¨0..8
┌9───────────────────────────────────────────────────────────────────────────────────────────────────────┐
│┌2─────┐ ┌2─────┐ ┌2───────┐ ┌2─────────┐ ┌2─────┐ ┌2───────┐ ┌2─────────┐ ┌2─────────────┐ ┌2─────────┐│
││  ┌1─┐│ │  ┌1─┐│ │  ┌2───┐│ │  ┌3─────┐│ │  ┌1─┐│ │  ┌2───┐│ │  ┌3─────┐│ │  ┌5─────────┐│ │  ┌3─────┐││
││0 │ 0││ │1 │ 1││ │2 │ 1 2││ │3 │ 1 1 2││ │4 │ 2││ │5 │ 2 4││ │6 │ 2 2 4││ │7 │ 2 1 1 1 4││ │8 │ 2 1 4│││
││~ └~─┘2 │~ └~─┘2 │~ └~───┘2 │~ └~─────┘2 │~ └~─┘2 │~ └~───┘2 │~ └~─────┘2 │~ └~─────────┘2 │~ └~─────┘2│
│└∊─────┘ └∊─────┘ └∊───────┘ └∊─────────┘ └∊─────┘ └∊───────┘ └∊─────────┘ └∊─────────────┘ └∊─────────┘3
└∊───────────────────────────────────────────────────────────────────────────────────────────────────────┘
  f 19
4 2 1 3 1 2 8
  f 54321x
233 14 1 1 3 2 1 2 1 1 1 1 3 4 6 6 1 1 2 7 1 13 4 11 8 11 4 13 1 7 2 1 1 6 6 4 3 1 1 1 1 2 1 2 3 1 1 14 466
  f 139
11 1 3 1 3 7 1 1 2 11 2 1 1 7 3 1 3 1 22
  +∘÷/f 139
11.78982612
  √139
11.78982612

if the argument is a square of a number it would return one list of 1 only element, the sqrt of that number
  f 4
2

If it would depend from me, in one exercise without "codegolf" I would prefer the previous edit that use function sqrti()...

surely you can use single-letter names instead of fq and a0. also: (a×Q)-P -> P-⍨a×Q

Q←Q÷⍨ - does nars support Q÷⍨←?

@ngn : I don't like to use " Q÷⍨←" in a chain of multiple assignment formula...for the remain agree... Possible I say that because I saw C Undefined Behavior

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


text:
Generate a valid equation using user-specified numbers
This is based on a game one of my math teachers used to play in middle school. He would write 5 random one-digit numbers on the board, and then a random two-digit number. We would try to create an equation that used all 5 of the one-digit numbers to yield the two-digit number.
Here are some examples with solutions to explain this better:
Input:           Solution:
7 5 4 8 4 34     5*8-7+4/4 = 34
3 1 5 7 6 54     (7+3)*6-5-1 = 54
3 9 2 1 6 87     9*(2+1)*3+6 = 87
2 1 6 9 7 16     (9-7+6*1)*2 = 16
2 4 5 8 6 96     8*(5+6)+2*4 = 96
3 8 4 5 4 49     8*(4+4)-3*5 = 49

This challenge is to write a program that can generate such equations for a given input.
The input can be provided either via the command line or via a prompt. The 5 one-digit numbers will always be entered first (in no particular order), followed by the two-digit number. The program will then print out a solution equation it finds; you do not have to handle situations where there is no solution. The function must be capable of using the following operations in the equation: addition, subtraction, multiplication, and division. If you would like to allow additional basic operations, that's fine as long as they remain in the spirit of the challenge (negation, exponentiation, and modulus would be nice additions). Order of operations follows the standard math rules, so parenthesis will be needed for grouping.
The program must take less than a minute to run on a modern computer.
Programs will be scored based on code length (including required whitespace).
Note: division must be exact, not rounded or truncated to nearest integer.

possible duplicate of Obtain a number from 4 numbers using any combination of mathematical operations

That is very similar task, but I think the additional term and no restriction on how expressions are grouped should expand the problem enough for it to be interestingly different. Additionally, this is a golfing challenge instead of a code challenge, which will call for different solutions.

What about concatenation? e.g. if given 7 5 4 8 4 34, output 7+54/8*4 would be allowed?

Python 2.7 (284), Python 3.x (253)
from __future__ import division #(Remove for Python 3.x)
from itertools import *
a=raw_input().split()
for i in permutations(a[:-1],5):
 for j in product('+-*/',repeat=5):
  for k,l in combinations(range(1,12,2),2):
   d=''.join(sum(zip(i,j),()))[:-1];d='('+d[:l]+')'+d[l:]
   if eval(d)==int(a[-1]):print d;b

It gives an error (calling unknown function b) on solution.
Basically, it's a gigantic brute force. It takes in the input, splits it by its spaces (1 2 -> [1,2]), and then permutes through that list. With every permutation, it will iterate through all possible strings of length 5 using the characters +-*/. With each of those iterations, it will generate the combinations of length 2 of the list [1,3,5,7,9,11], interweave the permutation and the string together (12345 *-/+- -> 1*2-3/4+5-), and put in the parentheses. Finally, it will evaluate it, and if the answer and equation are true, then it prints the equation and stops.
This is horribly inefficient, about O(n!/(n-5)!)=O(n^5), but it runs in a reasonable time for the test inputs.

The integer math can cause incorrect output when using division. For example, the input "3 6 8 7 1 29" yields "(3+8/6)*7+1", which equals 31 1/3, not 29. I'll update the description to make this explicit.

It gives (3/6)*8*7+1 for me.

Ok, I'll chalk that up as an issue with the interpreter I used.

Scala 368:
The 2nd g=-Line is more easy to test, the first is flexible to take command arguments, and both are of equal length, so I only count from the second one - remove it to do args passing:
val g=(args.map(_.toDouble))
val g=Array(3,9,2, 1, 6, 87)
val k="+*/-DQ"
val i=(0 to 5)
val f:Seq[(Double,Double)=>Double]=Seq(_+_,_*_,_/_,_-_,(a,b)=>b-a,(a,b)=>b/a)
val h=g.init.permutations;
for(j<-h;o<-i;p<-i;q<-i;r<-i;z=try{f(r)(f(q)(f(p)(f(o)(j(0),j(1)),j(2)),j(3)),j(4))}catch{case _ => 0}
if(z==g(5)))printf("(((%d%c%d)%c%d)%c%d)%c%d=%d\n",j(0),k(o),j(1),k(p),j(2),k(q),j(3),k(r),j(4),g(5))

Sample output (you might have a question right now - just a moment):
(((5+7)/1)+6)*3=54
(((5-7)D1)*6)*3=54
(((5D7)+1)*6)*3=54
(((5+7)+6)Q1)Q3=54

What about this 5D7 thing? D1? Is it hex? There is Q1, Q3 - what's that.
Sir_Lagsalot allowed new basic operations in the spirit of the challenge, and yes, these are basic operations, Delta and Quotient.
They are different from a/b and a-b in that aQb means b/a and aDb means b-a. Let's call it the Ukrainian notation.
So
(((5-7)D1)*6)*3=54

means
((1-(5-7))*6)*3=54
 (1-(-2))*6*3
   3*6*3 = 18*3=54

To the more interesting question of the how and why: In the beginning I got mad about the possibilities to place the parentheses, and whether (a+b)-c = a+b-c = (a+b-c) = ((a+b)-c) = (b+a)-c and so on. You can get mad over this question, but if you write down the possible parenthesis combinations, you sometimes throw away the scratch sheet and face the fact: You always perform 4 operations between 5 values, and you always start with one of them. If the pattern is always (((_x_)x_)x_)x_ ?= _ (x being one of the 4 operators) and allow the opposite direction ( x b) and (b x a), you addressed every possibility.
Now for a+b and a*b we don't need no opposite direction, they are commutative. So I invented the D and Q operator, which just switch the direction. I now have 2 operators more, but don't need to switch direction. Well - it is done in the function Sequence:
 (a,b)=>b-a,(a,b)=>b/a

My for-comprehension takes the values from the Array g, and distributes them on a to e, then I pick 4 indexes to pick the function and later the (only by index) associated operator symbol. I have to catch div/0 errors, since subtraction can lead to zeros, while the sample input data doesn't contain a 0.

The Delta and Quotient operators are fine. If you plan on golfing though, you'll need to add parenthesis to the output.

The output now prints parenthesis.

source: Stack Exchange

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

sort: votes


text:
generate a valid equation using specified operators
A twist on a recently asked question, you are given a list of operators and a result and you need to find integers which, when operated on by those operators, generate the result.
Example 1
input
+ + * / 13

possible output
4 8 2 2 4

which means that 4 + 8 + 2 * 2 / 4 = 13.
More specifically, you are given a sequence of N operators (between 1 and 5 inclusive) and an integer result, space separated.  You must print N+1 integers, space separated, in the range 1 through 9, inclusive, that when alternated with the operators produce the result.
The operators are +,-,*,/.  They have the natural precedence order (* and / before + and -, left associative).  Divides must be integral divides, a divide with a fractional result is not allowed.  Operators must appear in the order given.
Most problems will have more than one solution.  Printing any of them, or any subset of them, is fine.  If there is no solution, print NO SOLUTION.
Example 2
input
/ + - - 16

output
9 1 9 1 1

Example 3
input
+ 5

output
1 4
2 3
3 2
4 1

(or any nonempty subset of those lines)
Example 4
input
+ + 30

output
NO SOLUTION

Example 5
input
/ + / 3

output
6 3 5 5

note that 3 2 3 2 is not a solution, as 3/2+3/2=3 is true but the individual divides have fractional values.
Standard code golf, shortest answer wins.

Just to clarify something for me: is 9 2 a valid solution if the input is / 4?

@Gareth, no it isn't.  That is a divide with a fractional result.

Any chance the result can be printed without spaces?

@Steven: nope, format as specified.

Perl, 129 160 151 chars
sub a{my($s,$t,$o)=splice@_,0,3;@_?map{a("$s $_","$t$o$_",@_)}1..9:
$o-eval$t||$o-eval"use integer;$t"||exit say$s}a"","","",split$",<>;say"NO SOLUTION"

Fun with recursion. The program exits upon finding the first valid tuple.
The eval has to be done twice, in and out of integer-only mode, in order to avoid invalid solutions like that given in example 5 in the description.

Python (197 212 277)
Related question, related answer. Gives the answer and an error if there is one, else prints "NO SOLUTION".
import re,itertools as I
e=eval;a=raw_input().split();c=1;b=len(a)
for i in I.product('123456789',repeat=b):
 d=''.join(sum(zip([j+'.'for j in i],a),()))[:3*b-1]
 if e(d)==int(a[-1])and all([e(n)%1==0 for n in re.findall('\d./\d.',d)]):print' '.join(i);c=0
print"NO SOLUTION"*c

This doesn't work for me, e.g. + 5 doesn't work.  It doesn't handle / correctly (in either 2.x or 3.x), and I don't want exceptions in my output :)

Fixed it. Man, that increased the code size.

Scala 333
val o=args.init
val e=args.last
val n=(1 to 9)
val i=new bsh.Interpreter
def b(o:Array[String],s:String=""):Boolean={
if(s.isEmpty)n.exists(y=>b(o,s+y))else
if(o.isEmpty){
val r=i.eval(s)
if(r.toString==e){
println(s.replaceAll("[-*+/]"," "))
true}else false}else
n.exists(x=>b(o.tail,s+o(0)+x))
}
b(o)||{println("NO SOLUTION");true}

Python 2.7, 192 190 184 181 chars
Getting rid of itertools.product saved 3 characters.
s=raw_input().split()
j=' '.join
s[-1]='=='+s[-1]
n=len(s)
x=[j(i)for i in map(str,range(10**(n-1),10**n))if'0'not in i and eval(j(map(j,zip(i,s))))]
print x and x[0]or"NO SOLUTION"

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


text:
Shortest terminating program whose output size exceeds Graham's number
Write the shortest possible program (length measured in bytes) satisfying the following requirements:

no input
output is to stdout
execution eventually terminates
total number of output bytes exceeds Graham's number

Assume that programs run until "normal" termination on an ideal computer1 able to access unlimited resources, and that the common programming languages are modified if necessary (without changing the syntax) to allow this. Because of these assumptions, we might call this a kind of Gedankenexperiment.
To get things started, here's a 73-byte Ruby program that computes fω+1(99) in the fast-growing hierarchy:
f=proc{|k,n|k>0?n.times{n=f[k-1,n]}:n+=1;n};n=99;n.times{n=f[n,n]};puts n

1 EDIT: More precisely, suppose we're taking an existing system and modifying it only to have no upper limit on storage size (but it is always finite). The execution-times of instructions are not supposed to be modified, but the machine is assumed to be ideal in that it will have no upper limit on its operating lifetime.

This takes my tetration question to a whole new level!

There was once a similar programming contest called the Bignum Bakeoff. Some of the entries are quite interesting; the results are here: http://djm.cc/bignum-results.txt

Binary Lambda Calculus, 78 bits = 9.75 bytes
Here is an expression in Binary Lambda Calculus that is less than 10 bytes, yet surpasses Graham's Number. This is over 5x shorter than my previous post in JavaScript. Since Binary Lambda Calculus is radically different than JavaScript, I decided to answer this in a separate post.
010101000001110011101000000101011000000101101101011010000110100000011100111010

You can find some interpreters here.
Explanation I made on another post
Essentially, this binary expression encodes this lambda calculus expression:
(\f x.f (f x))(\f n.n (\g m.m g m) f n)(\x.x x)(\f x.f (f x))

The decodings can be described like this:

(\f x.f (f x)) at the start and at the end corresponds to the Church Numeral \$2\$.
(\f n.n (\g m.m g m) f n) takes in a function \$f\$ and a number \$n\$, and returns \$f_n (n)\$ where \$f_0 (n) = f(n)\$ and \$f_{m+1} (n) = f_m^n (n)\$ using functional recursion. Let's call this function \$S\$.
(\x.x x) corresponds to the function that raises a number to the power of itself, or \$f(x)=x^x\$.

Since Church Numerals naturally nest the function that they apply to, the lambda calculus string gets reduced as follows:
$$2Sf2 \rightarrow S(Sf)2$$
Since each \$S\$ adds \$\omega\$ to the growth rate of the function, and the \$f(x)=x^x\$ has growth rate \$f_2\$ in the Fast Growing Hierarchy, then \$(Sf)\$ has growth rate \$f_{\omega}\$, and \$S(Sf) = 2Sf\$ has growth rate \$f_{\omega2}\$.
This means the expression \$2Sf2\$ described above has the value of about \$f_{\omega2} (2)\$ in the Fast-growing Hierarchy. This is greater than Graham's Number.
Therefore, Graham's Number can be beaten by a program that less than 10 bytes!

You can remove 1 byte by doing (\t. t S f t) 2 -> 2 S f 2 at the beginning. The 70 bits: 0100010101100000010101100000010110110101101000011010100000011100111010

63 bits: 010001010110010110000000010101101110110101010100000011100111010. This encodes (\t.t (t (\h g m.m h g m) t) t t) (\f x.f (f x)) and becomes 2 (\f n.n (\g m.m 2 g m) f n) (\x.2 x) 2, which is greater than 2 S f 2.

@2014MELO03 Unfortunately, my lambda-fu is not good enough to confirm the "... and becomes ..." in your last comment. Would you (or anyone) be so kind as to briefly describe the main steps involved in that conversion?

I just wrote a post about this program at https://googology.fandom.com/wiki/User_blog:JohnTromp/The_largest_number_representable_in_64_bits

@JohnTromp Does it output anything to stdout? This program computes a Church numeral, not a string. The number 2 doesn't output "2".

@2014MELO03 That website is for BLC8, the byte oriented variant. For BLC itself, there are several I/O conventions. For use in AIT, https://tromp.github.io/cl/Binary_lambda_calculus.html#Complexity.2C_concretely defines output for the universal machine for either delimited or self-delimiting programs. This entry is for Busy Beaver rather than AIT purposes, so the output is defined according to https://oeis.org/A333479 as the term's normal form. If you could please send me email, we can continue to discuss there.

@JohnTromp Your googology blog posting is very helpful, especially the easy-to-follow proof sketch -- thanks! That proof of course bypasses any need to show 2 (\f n.n (\g m.m 2 g m) f n) (\x.2 x) 2 eventually arises -- although I would still be interested in knowing how to show it does.

@r.e.s. Replacing (\f x.f (f x)) with 2: (\t.t (t (\h g m.m h g m) t) t t) 2 -> 2 (2 (\h g m.m h g m) 2) 2 2. This new expression has 4 terms, the first and last term (both 2) stay the same. The 3rd one (2) is equivalent to (\x.2 x). The 2nd term will be further reduced: 2 (\h g m.m h g m) 2 -> (\h g m.m h g m) ((\h g m.m h g m) 2) -> (\h g m.m h g m) (\g m.m 2 g m). Renaming some variables to avoid confusion we get: (\h f n.n h f n) (\g m.m 2 g m) and finally the second term becomes (\f n.n (\g m.m 2 g m) f n).

@2014MELO03 @JohnTromp It's only the (\x. 2 x) that I don't get. I apologize if this is something elementary, but letting T = (H (H 2)) in (2 T 2 2)=(((2 T) 2) 2), why can we say that the 3rd term (the second 2 from the right) "is equivalent to (\x.2 x)"?

@r.e.s. If we give any argument n to 2 we will have 2 n. If we give the same argument n to (\x.2 x) we will have (\x.2 x) n -> 2 n. Both reduce to the same term once any argument is given. Iff two functions give the same result for every argument, they are the same function. This is called η-reduction.

@2014MELO03 Aaarrg ... it is too trivial :( Thank you for removing my misery!

Haskell, 59 57 55 63
(f%s)1=s;(f%s)n=f.(f%s)$n-1
main=print$((flip((%3)%(3^))3)%4)66

How it works: % simply takes a function and composes it n-1 times on top of s; i.e. %3 takes a function f and returns a function of n that equals applying it f to 3, n-1 times in a row. If we iterate the application of this higher-order function, we get a fast-growing sequence of functions – starting with exponentiation, it's exactly the sequence of Knuth-arrow-forest sizes:
((%3)%(3^))1 n = (3^)n     = 3ⁿ = 3↑n
((%3)%(3^))2 n = ((3^)%3)n = (3↑)ⁿ⁻¹ $ 3  = 3↑↑n
((%3)%(3^))3 n = (((3^)%3)%3)n = (3↑↑)ⁿ⁻¹ $ 3  = 3↑↑↑n
 and so on. ((%3)%(3^))n 3 is 3 ↑ⁿ 3, which is what appears in the calculation to Graham's number. All that's left to do is composing the function (\n -> 3 ↑ⁿ 3) ≡ flip((%3)%(3^))3 more than 64 times, on top of 4 (the number of arrows the calculation starts with), to get a number larger than Graham's number. It's obvious that the logarithm (what a lamely slow function that is!) of g₆₅ is still larger than g₆₄=G, so if we print that number the output length exceeds G.
⬛

When I test this with print$((flip((%3)%(3*))3)%2)1, there's a run-time error - can you say why? It succeeds when the 2 is changed to 1 (output is 81).

Oh... ideone seems to run a 32-bit version, so it gets to an overflow of Int quickly. On a 64-bit system, that consumes too much memory to reproduce, but of course it still won't allow to reach G. I need the (big-int) Integer type, so I can't use !!; wait...

Fixed it now, had to use explicit recursion to implement %.

I find ((%3)%(3*))2 n actually grows faster than you say (a good thing), but my Haskell-fu is inadequate to understand why. For n = 0, 1, 2, ..., instead of giving 3, 3^3, 3^(3^3), ..., it gives 3, 3^(3+1), 3^((3^(3+1))+1), ....

As I said: "((%3)%(3*))n 3 is larger than 3 ↑ⁿ 3". Or do you mean something else? Anyway, I changed the definition so that it's all equalities (at least I think so, to lazy to check now...) rather than larger-thans. And if you change 66 to 65, it actually produces G itself, ain't that nice?

With respect to the program before your latest changes, I wrote 2 n, not n 3: ((%3)%(3*))2 n grows faster than what you said, i.e. faster than 3↑↑n. The specific growth pattern is in my previous comment, and I don't understand Haskell syntax well enough to know what produced the +1 in that pattern. But I think your new version eliminates this discrepancy, and it's very neat that now your ((flip((%3)%(3^))3)%4)n produces exactly g_(n-1), where g_64 is Graham's number.

I'm struggling with the syntax, and it would help immensely if I could see why, given your definition of %, does ((%3)%(3^))2 n == ((3^)%3)n. I'm deriving (incorrectly?) that ((%3)%(3^))2 n == ((%3).(3^))n, then not seeing why ((%3).(3^))n==((3^)%3)n. (I know comments are not the place for lengthy discussion, but perhaps something brief will help others too?)

Hm... I suppose this wouldn't suffice for a StackOverflow question, would it? I could of course explain it in more detail here, but this challenge isn't really about how Haskell function compositions work, is it?

No, of course this challenge isn't about how Haskell syntax works (hence my remark about brevity). SO might be the best idea. (I'm about to go offline for the day, though -- maybe I'll post something there later.) Thanks for your answer ... I'm trying to grok Haskell because of it.

GolfScript (49 47 chars)
4.,{\):i\.0={.0+.({<}+??\((\+.@<i*\+}{(;}if.}do

See Lifetime of a worm for lots of explanation. In short, this prints a number greater than fωω(2).

f_(ω^ω)(2) is about as large as g_(f_8(8)), so not as overkill as that expression would imply.

Binary Lambda Calculus, 7.625 7.5 6.75 6.125 bytes, 61 60 54 49 bits
0100011010000110011000000101101100000011100111010

This encodes:
(\x.x x) (\y.y (y (\g m.m g (\f n.f (f n)))))

To simplify things a bit, let H = (\g m.m g 2) where 2 is the Church numeral (\f n.f (f n)). These are the first few steps of the reduction:
(\x.x x) (\y.y (y H))
(\y.y (y H)) (\y.y (y H))
(\y.y (y H)) ((\y.y (y H)) H)
(\y.y (y H)) (H (H H))
H (H H) (H (H H) H)
H (H H) H (H H) 2
H (H H) 2 (H H) 2
2 (H H) 2 (H H) 2
H H (H H 2) (H H) 2
H H 2 H 2 (H H) 2
2 H 2 H 2 (H H) 2
H (H 2) H 2 (H H) 2
H (H 2) 2 2 (H H) 2
2 (H 2) 2 2 (H H) 2
H 2 (H 2 2) 2 (H H) 2
H 2 2 2 2 2 (H H) 2
2 2 2 2 2 2 (H H) 2
2^^6 (H H) 2

The next step is applying H H \$2\uparrow\uparrow6\$ times to 2. After an odd number of aplications the result is not a number, but after an even number of aplications it is. Here \$2\uparrow\uparrow6\$ is not an aproximation, and since it is even, the final answer will be a number. We will use \$\frac{2\uparrow\uparrow6}{2}\$ times a function that applies H H twice. The function H H (H H n) grows as fast as the Ackermann function, to see this, let's take a look at a more general case. The function k H 2 n grows as fast as \$2\uparrow^kn\$:
0 H 2 n = 2 n = n^2 > 2*n = 2{0}n

k+1 H 2 n = H (k H 2) n = H (\x.k H 2 x) n >= H (\x. 2{k}x) n
    = n (\x. 2{k}x) 2 = 2{k+1}(n+1) > 2{k+1}n

Applying this to H H (H H n) we get H H (H H n) = H H n H 2 = n H 2 H 2 = H (n-1 H 2) H 2 = H (n-1 H 2) 2 2 = 2 (n-1 H 2) 2 2 = n-1 H 2 (n-1 H 2 2) 2 >= n-1 H 2 2{n-1}2 2 >= 2{n-1}2{n-1}2 2 = 2{n}3 2 > 2{n}3, which is about the same as \$A(n,n)\$. So the size of the expression 2^^6 (H H) 2 is about \$g_{\frac{2\uparrow\uparrow6}{2}} > g_{64}\$.

Brilliant! This deserves way more up votes. I've detailed the proof a bit more at https://github.com/tromp/AIT/blob/master/fast_growing_and_conjectures/melo.lam

Always knew BLC was concise, but wow.

Python 3, 53 bytes
m=lambda x:-x if x<0 else m(x-m(x-1))/2;print(1/m(9))

It computes the reciprocal of the gap between the 9 and the smallest tame fusible number above it, which is shown here to be at least \$f_{\varepsilon_0}(2)\$ in the fast-growing hierarchy, thus beating Graham's number.
Pyth, 24 22 bytes
-2 bytes thanks to r.e.s.
DlHR?<HZ_H/l-Hl-H12)lT

Same algorithm as before. I changed the argument 9 to 10 (which due to the predefined variable T doesn't increase the length), thus making the output at least \$f_{\varepsilon_0}(3)\$, absolutely dominating Graham's number and every other answer so far.

This is very cool! I think you can also make a great submission to Write a program whose nontermination is independent of Peano arithmetic based the termination of M for all natural numbers. (Edit: Or not, the "for all" quantifier goes the wrong way.)

By the way you can golf the base case to -x*(x<0)or ...

You don't need to take the reciprocal, because it's just the total number of output bytes that matters.

This program is an infinite loop due to floating point precision. While Python ints are arbitrarily long, Python floats are not. We get m(9) = m(9 - m(8 - m(7 - m(6 - m(5 - m(4 - m(2.999023318232446)/2/2/2/2)/2)/2)/2)/2)/2)/2, which then recurses forever at m(2.999023318232446) = m(2.999023318232446 - 1.1102230246251565e-16)/2 = m(2.999023318232446)/2. Consider using the fractions module or pairs of ints.

@AndersKaseorg @E.Z.L. The program will avoid floating point if it's considered to be in the SageMath language (rather than Python), where the variables default to Integer and Rational types. In this language, the program can also be shortened to 43 bytes: M=lambda x:-x if x<0else M(x-M(x-1))/2;M(9)'

Pyth, 29 28 bytes
M?*GHgtGtgGtH^ThH=ZTV99=gZTZ

Defines a lambda for hyper-operation and recursively calls it. Like the definition for Graham's number, but with larger values.
This:
M?*GHgtGtgGtH^3hH

Defines a lambda, roughly equal to the python
g = lambda G, H:
  g(G-1, g(G, H-1)-1) if G*H else 3^(H+1)

This gives the hyper-operation function, g(G,H) = 3↑G+1(H+1).
So, for example, g(1,2)=3↑23 = 7,625,597,484,987, which you can test here.
V<x><y> starts a loop that executes the body, y, x times.
=gZT is the body of the loop here, which is equivalent to Z=g(Z,10)
The code:
M?*GHgtGtgGtH^3hH=Z3V64=gZ2)Z

Should recursively call the hyperoperation above 64 times, giving Graham's Number.
In my answer, however, I've replaced the single digits with T, which is initialized to 10, and increased the depth of recursion to 99. Using Graham Array Notation, Graham's Number is [3,3,4,64], and my program outputs the larger [10,11,11,99]. I've also removed the ) that closes the loop to save one byte, so it prints each successive value in the 99 iterations.

Javascript, 50 Bytes, \$f_{\omega+8} (9)\$
n=(y,x=9)=>y?y-9?n(y-1,x?n(y,x-1)*9:9):x:n(x);n(8)

Here, n is a binary function. The function is defined as followed:

n(9,x) = x
n(y,0) = n(y-1,9)
n(y,x) = n(y-1,n(y,x-1)*9)

The *9 ensures that n(y,x) is an increasing function with respect to x.

n(9,x) = x
n(10,x) = 9^(x+1)
n(11,x) ~ 9^^x
n(12,x) ~ 9^^^x
n(y+1,x) recurses over n(y,x) with respect to x.

We also defined n(y)=n(y,9), so n(y) grows as fast as  \$f_{\omega}\$  in the Fast Growing Hierarchy.
Now here is the twist:

n(0,x)=n(x)=n(x,9)

This starts an entirely new hierarchy starting from y=0 all the way up to y=8.

n(0,x) grows at \$f_{\omega}\$ in the FGH
n(1,x) grows at \$f_{\omega+1} = G\$
n(2,x) grows at \$f_{\omega+2}\$
...
n(8,x) grows at \$f_{\omega+8}\$

Therefore, n(8) ~ \$f_{\omega+8} (9) > G_{64}\$

Ruby, 54 52 50 bytes
f=->b{a*=a;eval"f[b-1];"*b*a};eval"f[a];"*a=99;p a

Ruby, 85 81 76 71 68 64 63 59 57 bytes
f=->a,b=-a{eval"a*=b<0?f[a,a]:b<1?a:f[a,b-1];"*a};p f[99]

Pretty much fast growing hierarchy with f(a+1) > fω+1(a).

Ruby, 61 bytes
f=->a,b=-a{a<0?9:b==0?a*a:f[f[a-1,b],b>0?b-1:f[a,b+1]]};f[99]

Basically an Ackermann function with a twist.

Ruby, 63 59 bytes
n=99;(H=->a{b,*c=a;n.times{b ?H[[b-1]*n*b+c]:n+=n}})[n];p n

Another Ruby, 74 71 bytes
def f(a,b=a)a<0?b:b<0?f(a-1):f(a-1,f(a,b-1))end;n=99;n.times{n=f n};p n

Basically Ackermann function to itself 99 times.

Python (111+n), n=length(x)
Although this one is not as short as the answerer's Ruby program, I'll post it anyway, to rule this possibility out.
It uses the Ackermann function, and calls the Ackermann function with m and n being the values from another call to the Ackermann function, and recurses 1000 times.
This is probably bigger than Graham's number, but I'm not sure, because nobody knows the exact length of it. It can be easily extended, if it's not bigger.
x=999
b='A('*x+'5,5'+')'*x
def A(m,n):n+1 if m==0 else A(m-1,A(m,n-1)if n>0 else 1)
exec('print A('%s,%s')'%(b,b))

output to stdout?  also, you need a return statement or a lambda.

Also if A(m,n) returns a single value, then isn't A(A(5,5)) missing an argument? ... This is the problem with a challenge like this: it encourages people not to test their code, because a complete run is purely theoretical.

If you replace your last line with exec'x=A(x,x);'*x;print x, then the program is ok and the output is approximately f_(ω+1)(x) (assumimg the Ackermann function code is correct), which has more than G bytes even for x=99, say. (In my Ruby program, f[m,n] is a version of A(m,n).)

@breadbox - Good point ... Theoretical questions like this require us to make sure a program is ok for small-parameter (i.e. non-theoretical) test-cases that clearly generalize to give a correct answer.

Its's longer, but if you want to use eval instead of exec, your last line could be f=lambda x:A(x,x);print eval('f('*x+'x'+')'*x). Also, your def of A(m,n) needs to be corrected per boothby's comment.

Boothby: Yes, something I forgot to do. Breadbox: Yep, I noticed that at about midnight, when I was in bed, half-asleep. r.e.s: Will do. Thanks, guys!

@breadbox: Except if you have an compiler, which proves your theorem for free.

GolfScript, 24 20 18 bytes
"`'1$,*~'+"{.~~})*

Try it online!
"`'1$,*~'+"         # Push this string
           {.~~})*  # Becomes {.~}126* and this duplicates and executes the string 126 times

When executed, this string modifies the string at the top of the stack:
 `          # Parse it to a string inside the string  'foo'  -> '"foo"'
  '1$,*~'+  # Add '1$,*~' at the end                  '"foo"' -> '"foo"1$,*~'

When we execute this new string it does whatever foo used to do, but many times.
     1$,     # Get the number of bytes of the string at the top of the stack
"foo"   *    # Make that many copies of foo
         ~   # Execute all of them

We will be dealing with only one string, that will modify itself 126 times. Let L be the number of loops and B the number of bytes the string has. These values can be calculated with \$B=2^{L+1}+3L+7\$, but for simplicity's sake we will round B down to L. The number of bytes grows exponentially because every time a loop is added, every " becomes \" and every \ becomes \\. Now the loops execute L times instead of B. When the string has no loops it just adds " "1$,*~ around itself, in other words L = L + 1. With a loops it executes L times the version with a-1 loops. This is exactly the same definition of f in the fast growing hierarchy for when a is a successor:
$$f_0(L)=L+1$$
$$f_a(L)=f_{a-1}^L(L)$$
Before each execution a and L are the same number, so every time we execute the string, L becomes \$f_\omega(L)\$.
We execute it 126 times starting with L = 0, so the number of bytes in the output will be:
$$f_\omega^{126}(0)=f_\omega^{122}(f_8(8))>f_\omega^{122}(122)=f_{\omega+1}(122)$$

Functoid, 14 bytes
B"W(BiCA])9.Ef

Try it online!
The pointer wraps around whenever it moves out of the source code, this happens once here, making the code equivalent to B"W(BiCA])9.EfB"W(BiCA])9.Ef. The string "W(BiCA])9.EfB" gets converted to base 10 and becomes "91772447243986". Now we can rewrite the code as BkW(BiCA])9.Ef, where k represents that big number.
BkW(BiCA])9         # set the current function to B k W (B i C A ]) 9
           .        # evaluate and print the current function as a number
            Ef      # terminate the program

Let f_a be a lambda function equivalent to \$f_a\$ in the fast growing hierarchy. To increase the index by 1, the function needs to be applied to itself n times \$f_a^n(n) = f_{a+1}(n)\$. In code this would be f_(a+1) n = n f_a n = C A f_a n. To get any finite index we just need to apply C A a lot of times to f_0 = ]:
f_0 = ]
f_1 = C A ]
f_2 = C A (C A ])
f_3 = C A (C A (C A ]))
...

\$f_\omega(n) = f_n(n)\$ = n (C A) ] n = W (i (C A) ]) n
The expression B k W (B i C A ]) 9 can be reduced to k (W (i (C A) ])) 9 = k f_ω 9 and this returns \$f_\omega^{91772447243986}(9)\$.

Python 3, 79 bytes
f=lambda x,y:f(x-1,f(x,y-1))if x*y else x+y+1
z=9;exec("z=f(z,z);"*99);print(z)

f(x,y) is a modified version of ackermann for golfing purposes

f(x,y) = f(x-1,f(x,y-1)) if both x and y are greater than 0

f(x,0) and f(0,y) each add one to the nonzero entry (if both are zero, it is 1)
Then the program does recursion on f(x,x) 99 times.

Welcome to Code Golf, and nice answer!

JavaScript, 68 bytes, however uncompeting for using ES6
a=(x,y)=>y?x?a(a(x-1,y)*9,y-1):a(9,y-1):x;b=x=>x?a(9,b(x-1)):9;b(99)

a function is similar to up-arrow notation with base 9.
       /a(a(x-1,y)*9,y-1)  x>0, y>0
a(x,y)=|a(9,y-1)           x=0, y>0
       \x                  y=0

b function is: b(x)=bx(9).
b(99) is ~fω+1(99), compared to Graham's number<fω+1(64).

If you've marked this non-competing due to the language being newer than the question, you don't have to do that anymore

Python 3, 174 171 168 148 125 117 116 112 101 bytes
3^^^...^3 with Graham's number arrows i.e. G(65) (boring, I know)
a=lambda b,c:3if b<2else(a(a(b-1,c),c-1)if c else 3*b)
G=lambda k:a(3,G(k-1))if k else 4
print(G(65))

Pretty human-readable. a implements arrow notation, G is Graham's sequence.
Improvements

Replaced G(64)+1 with G(65), saving two bytes
Replaced if c==1:return a**b with if c==0:return a*b, saving one byte
Renamed ar function to a and renamed variable a to k, saving three bytes
Turned G function from a proper function into a lambda, saving twenty bytes, believe it or not!
Turned a function from a proper function also into a lambda, saving twenty-three bytes!
Removed k from a function since we will only be using it with base 3, saving eight bytes.
Removed an unnecessary space
Removed some more unnecessary spaces, saving four bytes
Shortened definitions of a and G, saving eleven bytes

You can save 7 bytes with a=lambda b,c:3if b<2else(a(a(b-1,c),c-1)if c else 3*b), and another 4 bytes with G=lambda k:a(3,G(k-1))if k else 4.

Thank you so much! I will definitely do that.

7, 17.5 bytes
00000000: 505e 91e7 a3a4 63c8 edda 476d ea0b d556  P^....c...Gm...V
00000010: d7e                                      ..

Written in octal:
24057221717216443074435566443555724057252555375

Try it online!
721gge644355 is a function that, given a function f_a(), returns f_(a+1)():
|f_a() 721gge644355
|c7{f_a()}ggerr          # Where {f_a()} represents the pacified version of f_a()

# Applying the result to some number n, to see that it worked:
|n c7{f_a()}ggerr
|n|f_a() nr
   f_a() n               # Make n copies of f_a(), resulting in f^n_a()
 n        r              # Apply it to n, resulting in f^n_a(n) = f_(a+1)(n)

From that, a function f_w() can be written:
|n cc71721644307443556ggerrr
|n|n|721gge644355 nrr
   n                              # A function (\x -> x^n), representing f_0()
     721gge644355 nr              # Add 1 n times to the index of f_0(), resulting in f_n()
 n                  r             # Apply the result to n, resulting in f_n(n) = f_w(n)

The full program computes f^256_w(2), which is greater than Graham's number:
|| 24057221717216443074435566443555724057252555375
||cg6r|cc71721644307443556ggerrr|cg6r|crcrrre|r
||cg6r|cc71721644307443556ggerrr|cg6r|crcrrre|r r
||cg6r|cc71721644307443556ggerrr|cg6r|crcrrre r
||cg6r|cc71721644307443556ggerrr|cg6r crcrrre
                                 cg6r              # The number 2
                                      cr           # Raise 2, to itself returning 4
                                        cr         # Raise 4, to itself returning 256
       cc71721644307443556ggerrr          r        # Make 256 copies of f_w(), resulting in f^256_w()
  cg6r                                     r       # Apply this function to 2, resulting in f^256_w(2)
                                            e      # Print the result in the same encoding as the source code

We can see the code working by reducing it to just f_w(2). This outputs 2^2^18, which is represented by 2^18 copies of 2405 in the same encoding as the source.
2405722171721644307443556644355575375

Try it online!

Python: 85
f=lambda a,a:a*a
exec'f=lambda a,b,f=f:reduce(f,[a]*b,1)'*99
exec'f('*64+'3'+',3)'*64

Which maybe could be shortened to 74 + length(X):
f=lambda a,a:a*a
exec'f=lambda a,b,f=f:reduce(f,[a]*b,1)'*int('9'*X)
f(3,3)

Where X is an appropriate big number such that the resultant hyperoperation on 3, 3 is bigger than Grahams number(if this number is less than 99999999999 then some byte is saved).

Note: I assume the python code is executed on the interactive interpreter hence the result is printed to stdout, otherwise add 9 bytes to each solution for the call to print.

Your 74ish byte solution does not produce an output nearly large enough.

Javascript, 83 bytes
Another Ackermann function solution.
(function a(m,n,x){return x?a(a(m,n,x-1),n,0):(m?a(m-1,n?a(m,n-1):1):n+1)})(9,9,99)

Ruby, 60 bytes
f=->n{n.times{eval("n.times{"*n+"n+=1"+"}"*n)};n};f.call(64)

This is \$f_{\omega+1}(64)\$, exactly, which is slightly bigger than Graham's number :) I copied this from Simply Beautiful Art on their Bignum Bakeoff post.

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


text:
Pythagorean Triplets
The Pythagorean Theorem states that for a right triangle with sides a, b, and c, a2+b2=c2.
A Pythagorean triplet is a set of three numbers, where a2+b2=c2, a
To extend this even further, a primitive Pythagorean triplet is a Pythagorean triplet where gcd(a,b,c)=1.
The goal is to find 100 primitive Pythagorean triplets.
Input: No input.
Output: 100 primitive Pythagorean triplets, in whatever order and shape, as long as the output contains only those triplets.
Shortest code wins. Good luck!

Is a < b or are  (a,b,c) and (b,c,a) 2 solutions.

@user unknown: a<b<c

They're called "triples", not "triplets".

Python, 42
i=4
while i<203:print 2*i,i*i-1,i*i+1;i+=2

i**2 -> i*i to save a couple of characters.

I should mark this as cheating, but oh well. :)

How is it cheating?

I was hoping everybody would actually generate the triplets by brute force, but I guess a math formula is fine too. :P

"hoping for brute force" -- there's something you don't hear every day.

@beary605 why have you accepted the answer that isn't the shortest?

Javascript, 44 characters
Update:
for(i=s=0;i^400;)s+=[i+=4,r=i*i/4-1,r+2]+' '

I should have looked up an algorithm first. Well, can't beat python anyway.
Run in a console to see the result.
Old, slow, brute-force variant (140 characters)
for(q=a=[];563>++a;)for(b=a;--b;)(k=Math.sqrt(a*a+b*b))==~~k==function c(e,d,f){return f?c(c(f,e),d):d?c(d,e%d):e}(a,b,k)&&q.push([b,a,k]);q

J, 64 60 38 49 characters
100$}.~.(/:~*(0<*/*1=+./))"1[4$.$.(=/+/~)2^~i.699

Should've realised that such a big gain was probably flawed. Still uses the brute-force method, but done a bit more efficiently.
Explanation:
x=.2^~i.699 generates a list of ints from 0 to 699 and squares 2^~ them (~ here reverses the order of the arguments).
(=+/~) is a hook that generates an addition table and compares the result to the list.  This gives me a three dimensional array with items which are either 1 or 0. A 1 means that a2+b2=c2.
$. converts to a sparse array. For my smaller (9) example I get:
   $.(=/+/~)2^~i.9
0 0 0 | 1
1 0 1 | 1
1 1 0 | 1
2 0 2 | 1
2 2 0 | 1
3 0 3 | 1
3 3 0 | 1
4 0 4 | 1
4 4 0 | 1
5 0 5 | 1
5 3 4 | 1
5 4 3 | 1
5 5 0 | 1
6 0 6 | 1
6 6 0 | 1
7 0 7 | 1
7 7 0 | 1
8 0 8 | 1
8 8 0 | 1

4$. just gives me the left part of this list.
(/:~*(0<*/*1=+./))"1[ decides which rows meet the criteria. (verb)"1 tells the verb to act on the individual rows rather than on the list. [ just separates the 1 and 4, otherwise J will think that 1 4 is a list of 2 numbers. '1=+./' gets the GCD of the three numbers and checks if it's 1. */ multiplies each triple together (getting 0 if it contains a 0) and these two are multiplied together. 0< turns the result into a boolean. * multiplies this result by each triple which eliminates all triples which contain a 0 or have a GCD which is not 1. /:~ sorts each triple.
~. selects the unique items from the list.
}. removes the first item (0 0 0) from the list.
100$ takes the first 100 items from the list.
The above is my answer to this question, but as a matter of interest I implemented grc's method, (27 characters):
2(*,.<:@^~,.>:@^~)2*2+i.100

Scala 180:
def g(a:Int,b:Int):Int=if(a==b)a else
if(a>b)g(a-b,b)else
g(b,a)
for(c<-(5 to 629);
a<-(1 to c-2);
b<-(a to c-1);
if((a*a+b*b==c*c)&&g(c,g(a,b))==1)&&a<400)println(a+"  "+b+" "+c)

Ungolfed:
def gcd (a: Int, b: Int) : Int = if (a == b)
  a else
    if (a > b) gcd (a-b, b) else
      gcd (b, a)

def gcd (a: Int, b: Int, c:Int): Int = gcd (c, gcd (a, b))

def pythagorean (a: Int, b: Int, c: Int) = (a * a + b * b == c * c)

for (c <- (5 to 629);
  a <- (1 to c-2);
  b <- (a to c-1);
  if (pythagorean (a, b, c) && gcd (a, b, c) == 1)) yield {
    println (a + "² + "  + b + "² = " + c + "² => " + (a*a) + " + " + (b*b) + " = " + (c*c))
    c*c
  }

APL (31)
↑{(2×⍵),(A-1),1+A←⍵×⍵}¨2+2×⍳100

It uses basically the same approach as the Python program.

MATLAB 29
i=2:2:200;[2*i;i.*i-1;i.*i+1]

Mathematica 33
{2#,#^2-1,#^2+1}&/@Range[4,203,2]

APL(NARS), 26 chars, 52 bytes
{k(4×⍵),2+k←¯1+×⍨2×⍵}¨⍳100

test:
  a←{k(4×⍵),2+k←¯1+×⍨2×⍵}¨⍳100
  ≢a
100
  +/{(x y z)←⍵⋄(z*2)=(y*2)+x*2}¨a
100
  +/{∨/⍵}¨a
100
  10↑a
3 4 5  15 8 17  35 12 37  63 16 65  99 20 101  143 24 145  195 28 197  255 32 257  323 36 325  399 40 401

R, 49 characters
translated from the Python solution:
i=4;while(i<203){print(c(2*i,i*i-1,i*i+1));i=i+2}

You should take advantage of the functional nature of R i=seq(2,200,2);c(2*i,i*i-1,i*i+1) (though the output is a bit messy).

Ops! I posted without taking a look at all the other answers! :-P


text:
Knight's tour on a rectangle
Given an a-by-b sized grid, and a chess knight, determine:

A starting point and path the knight can take to visit every square in the grid
or "NOT POSSIBLE", if not possible.

Input: Two integers, a, b.
Output: Numbers output in an a-by-b grid:
1 4 7 10
8 11 2 5
3 6 9 12

Where 1 is where the knight starts, a*b is where the knight ends, and the numbers signify the path the knight must take, in ascending order. The knight cannot land on the same square twice.
The rows of the grid must be separated with a newline, and the items in each row must be separated with a space.
Test Cases:
| is a newline.
3 4 -> 1 4 7 10 | 8 11 2 5 | 3 6 9 12
2 3 -> NOT POSSIBLE
If there is a solution there will be more than one: any valid solution is acceptable.
Shortest code wins. Please do not use any programming languages that are known to produce short programs: e.x. GolfScript, APL, J, K, etc.

Are coordinates able to be visited more than once? If so, should they counted/reported in the output?

@Gaffi: Nope, they can't.

@Gaffi I don't think that's valid, as 1 and 2 are on the same row. From 1 to 2 there should be a regular knight move. (see beary605's first test case result for an example)

OH, nevermind. The numbers in the expected output are the step numbers. I was going with the order/position of the spaces to move to. i.e. in my own example, you start at POS 1, then move to POS 7, which is the same as the original example, just formatted differently. I'll adjust my code on that. Sorry!

The recently added language restriction seems to be against the spirit of code golf, and is additionally rather vague on languages like Perl.

-1.  Although I have no desire to ever write solutions in GolfScript, APL, J, or K, I find this restriction irksome enough to warrant a down-vote (which I will rescind if you change the requirement).

@StevenRumbalski: I did this because I don't want people to take an easy answer, just because they coded in a character-compressed programming language. You may downvote if you like, but I want people to work to make their answers short.

@beary605:  I'll happily upvote any answer to this question in GolfScript, APL, J, K, or any similarly extremely terse programming language.  It's takes plenty of work to write short programs in those languages because it takes plenty of work to learn them.  I've coded all my answers in Python (except for one in Perl).  The game I play is that I try to be shortest among Ruby, Perl, Python, JavaScript, etc.  Doing so usually produces a satisfactory number of upvotes even if I don't "win".  Not winning is my fault for not taking time to learn the right tool for the job.

Writing GolfScript isn't easy. The debugging support is negligible, and you have to keep track of exactly what's on the stack at any time with no static checking to ensure you were right.

I just want languages of the same type. You can have either all terse, or all verbose. I don't want them mixing in this particular problem.

If you want to eliminate GolfScript, J, APL etc. from the answers to your questions, you should make the questions difficult, impractical or impossible to answer in those languages. (eg. require floats and GolfScript is out, the requirement for operator precedence in this question made it difficult enough for me to give up trying in J).

Ok. I will keep that in mind, if I ever come up with a question like that.

The language thing is ridiculous.  APL and K are not designed specifically to make short answers (like Golfscript for example) - they are programming languages people use in actual jobs (well paying ones too).  I know people that only know how to program in APL - they aren't even allowed to answer?

I've voted to close this question as unclear as "any programming languages that are known to produce short programs" is not properly specified

Ruby, 306 284 characters
w,h=eval"[#{gets}]"
f=Hash.new{|g,k|s,x,y,*r=k
x<0||y<0||x<w&&y<h&&s>0&&'$&(,268:'.bytes{|u|r|=f[[s-1,x-2+u%5,y-9+u/5]].select{|l|l[y*w+x]<1}}
g[k]=r.map{|l|l=l*1;l[y*w+x]=s;l}}
f[[1,0,0]]=[[1]+[0]*(w*h-1)]
(s=f[[w*h,w-1,h-1]][0]||(puts"NOT POSSIBLE"))&&s.each_slice(w){|f|puts f*" "}

Implementation in Ruby, takes input from STDIN and outputs to STDOUT. Although a little bit optimized it is still extremely slow on large grids.
> 5,3
NOT POSSIBLE

> 5,4
1 18 5 12 9
6 15 10 19 4
17 2 13 8 11
14 7 16 3 20

Edit: Ventero pointed out some improvements whiche saved several chars. I also changed the encoding of possible moves to be much shorter now.

You don't need the splat in front of k, instead of x>=0&&y>=0&& you can use x<0||y<0|| and you can parse the input using something like w,h=eval"[#{gets}]" to save a few characters.

@Ventero I don't know how I could miss that eval thing - did it several times before... Thank you very much.

Python, 420
w,h=input()
s=w*h
d=range
def r(l):y=l/w;x=l%w;return[x+p+w*(q+y)for p,q in[(1,2),(2,1),(-2,1),(-1,2),(-1,-2),(-2,-1),(2,-1),(1,-2)]if 0<=x+p<w and 0<=q+y<h]
def f(p):
 a={l:len(r(l))for l in r(p[-1])if l not in p}
 for l in[k for k in a if a[k]==min(a.values())]:
    x=f(p+[l])
    if len(x)==s:return x
 return p
e=f([0])
print len(e)<s and"NOT POSSIBLE"or'\n'.join([' '.join(`e.index(x+y*w)+1`for x in d(w))for y in d(h)])

I've sacrificed shorter code for reasonable performance, so it should be able to find solutions for boards up to 9x9 in under 3 seconds.

C# 796 793
using System;using System.Collections.Generic;using System.Linq;namespace Z{public class P{public static void Main(){new P().K(3,4);}int x, y;void K(int a, int b){x=a;y=b;for(var s=0;s<x*y;s++)K(new[]{s});Console.WriteLine("NOT POSSIBLE");}void K(int[] v){if(v.Length<x*y)foreach(var m in M(v))K(v.Concat(new[]{m}).ToArray());else{Console.WriteLine(String.Join("\n",v.Select((p,i)=>new{p,i}).OrderBy(e=>e.p).GroupBy(e=>e.p/y).Select(g=>String.Join(" ",g.Select(e=>e.i+1)))));Environment.Exit(0);}}IEnumerable<int> M(int[] v){var c=v.Last();var q=new{X=c/y,Y=c%y};return(from m in new[]{new{X=1,Y=2},new{X=2,Y=1}}from d in Enumerable.Range(0,4).Select(i=>new{X=(i&2)-1,Y=(i&1)*2-1})select new{X=q.X+d.X*m.X,Y=q.Y+d.Y*m.Y}into p where p.X>=0&&p.Y>=0&&p.X<x&&p.Y<y select p.X*y+p.Y).Except(v);}}}

This code finds a solution (if any) using brute force. Here's the ungolfed (and slightly refactored) version: http://pastie.org/4149829
Input: Modify the parameters in the new P().K(...); call.
Output: To the console, in the required format
Online demos:
Test Case 1 (3, 4): http://ideone.com/UU9sw (another solution than OP's, but it's a valid one)
Test Case 2 (2, 3): http://ideone.com/ZX9xC
A bigger board (4, 7): http://ideone.com/QKuXL (this takes close to 5s to run, so retry if it fails the first time).
Note: Mono does not have the String.Join method overload that takes as a parameter an IEnumerable<T>, so in order to get this working on IdeOne I have to modify the code a bit (modify these IEnumerable<T>s to string[]).

Ruby 364 359
K=->a,b{A,B=a,b;(0...A*B).each{|i|Z[[i]]};p"NOT POSSIBLE"}
Z=->v{c=v.last
abort (0...v.size).map{|i|{:i=>i+1,:x=>v[i]}}.sort_by{|i|i[:x]}.map{|i|i[:i]}.each_slice(B).map{|r|r*' '}*?\n if v.size==A*B
([[1,2],[2,1],[-2,1],[-1,2],[-1,-2],[-2,-1],[2,-1],[1,-2]].map{|d|o=(c/B)+d[0]
u=(c%B)+d[1]
(o>=0&&0<=u&&A>o&&B>u)?o*B+u :-1}.flatten-[-1]-v).each{|i|Z[v+[i]]}}

Same idea as my C# answer.
This gets invoked like this: K[a,b] and outputs the desired result to the console.
Online demos:
Test case 1: http://ideone.com/yDiiS
Test case 2: http://ideone.com/WVUmX
Example of a bigger board (4x5): http://ideone.com/hItNo

Python, 316
Took about 30 minutes to run on input of 3 4.  I wouldn't try it on anything larger.
import itertools as I
r=range
x,y=map(int,raw_input().split())
m=[(a,b)for a in r(x)for b in r(y)]
q=[n for n in I.permutations(m,x*y)if all((abs(o[0]-p[0]),abs(o[1]-p[1]))in((1,2),(2,1))for(o,p)in zip(n,n[1:]))]
print'\n'.join(' '.join([`q[0].index(z)+1`for z in m][i:i+y])for i in r(0,x*y,y))if q else"NOT POSSIBLE"

I notice the other Python answers get input by doing x,y=input() rather than x,y=map(int,raw_input().split()), but the question does not allow for commas in the input so it seems the former method would fail.  If the question does allow commas in the input, I'll shave an additional 20 characters off my answer.
I tried a recursive solution, but the best I could get was 334 characters:
r=range
x,y=map(int,raw_input().split())
m=[(a,b)for a in r(x)for b in r(y)]
o=[]
def f(m,x=0):
 for n in m:
  if x==0 or map(lambda x,y:abs(x-y),n,x)in([1,2],[2,1])and not o:
   if len(m)==1 or f(m-{n},n)or o:o.append(n)
f(set(m))
print'\n'.join(' '.join([`o.index(z)+1`for z in m][i:i+y])for i in r(0,x*y,y))if o else"NOT POSSIBLE"

VBA 494 574 833 chars
Fixing to account for the transposed example added quite a bit of code...
I squeezed a little more out be shifting around some If checks to avoid using End If.
This now correctly handles 4, 5 and 5, 4, but it takes impossibly long for 4, 7, and I'm not 100% sure it works for that set.
Dim z,v,e,i,j,p,l
Sub k(a,b)
e=a*b:q:i=2
If c(a,b) Then z(e)=e:j=e+1
For i=1 To e:s=s & z(i) & IIf(i Mod b=0,vbCr,vbTab):Next
MsgBox IIf(j-1=e,s,"NOT POSSIBLE")
End Sub
Sub o()
z(l)=j:v(l)=1:p=l:i=p:j=j+1
End Sub
Sub u(r,t)
z(r)=0:v(r)=0:p=t:j=j-1
End Sub
Sub q()
ReDim z(1 To e),v(1 To e):z(e)=e:v(e)=1:p=1:z(1)=p:v(1)=p:j=2
End Sub
Function w(b)
f=(p-1) Mod b+1:m=(l-1) Mod b+1:g=Int((p-1)/b)+1:n=Int((l-1)/b)+1:w=(((f-2=m Or f+2=m) And (g-1=n Or g+1=n)) Or ((f-1=m Or f+1=m) And (g-2=n Or g+2=n)))
End Function
Function c(a,b)
t=p:m=i:
If i>1 And i<e Then
For h=1 To 8:l=p+Choose(h,(b-2),(b+2),(2*b-1),(2*b+1),-(b-2),-(b+2),-(2*b-1),-(2*b+1)):r=l:If l>1 And l<e Then If v(l)=0 Then If w(b) Then o:If j>=e Then l=j:If w(b) Then c=1 Else u r,t Else c=c(a,b):If c=0 Then u r,t
Next:End If
If c=(i>=e) Then i=m+1:c=c(a,b)
End Function

And wouldn't you know it. I only tested on the two examples given. This does work for 3 4, but not for 4 3 (which should be equivalent, transposed answers...) Looking into this.

Looking at this more carefully, I don't believe it will actually accurately catch all solutions. Some recursion will fix that (and more code) but I will have to come back to it later...

I've tested it and it runs fine for both 3,4 and 4,3. However, it says "NOT POSSIBLE" for 4,5, which has a solution: http://ideone.com/y5hl1

@w0lf Right, and I know what the issue is; I just have to get some time to fix it.

Python, 370 367 366 338
Simple recursive solution. It isn't efficient, but works fast for example cases :-)
import itertools as I
P=I.product
a,b=input()
r=range;A=r(a);B=r(b);T={}
def S(x,y):
 if 0<=x<a and 0<=y<b and(x,y)not in T:
    T[x,y]=len(T)+1
    for i,j in P((-2,2),(-1,1)):S(x+i,y+j);S(x+j,y+i)
    if len(T)!=a*b:T.pop((x,y))
for q,w in P(A,B):S(q,w)
print"\n".join(" ".join(str(T[i,j])for j in B)for i in A)if len(T)==a*b else'NOT POSSIBLE'

A,B,T=range(a),range(b),{} -> r=range;A,B,T=r(a),r(b),{}. any(S(q,w) for q,w in P(A,B)) -> any(S(q,w)for q,w in P(A,B)). If you state C=(-2,2);D=(-1,1), you can go list(P(C,D))+list(P(D,C)) instead to save 1 character.

APL (Dyalog Extended), 22 bytes (SBCS)
⊃⌂kt,⍥⊆'NOT POSSIBLE'⍨

Try it online!
⊃ the first of…
⌂kt the first knights tour (if possible, else: an empty list)
,⍥⊂ juxtaposed with
'NOT POSSIBLE'⍨ the required fall-back value


text:
Generate Sexy Primes
Sexy Primes are pairs of numbers \$(n, n+6)\$ such as \$n\$ and \$n+6\$ are both prime
You need to create a function which will take an integer, check for sexy primes from 0 to that integer, and return an array of arrays.
For example, listSexy(30) must return [[5,11], [7,13], [11,17], [13,19], [17,23], [23,29]] or some equivalent.
This is code-golf so the program with the shortest bytecount wins!

Can you explain what the desired output format looks like?

Bah, I hate it when the challenge changes after answers have been submitted.

Is there a certain reason to check from 0? Why shouldn't I check from (5,11)? A short definition of sexy primes should be given right here, while linking to Wikipedia for further reading is welcome.

In Portuguese Sexy Primes translates to the same as Sexy Cousins!

@sergiol haha...

MATLAB 32
i=1:n;i(isprime(i)&isprime(i+6))

n is your number

+1 That is the right tool for the job: isprime. Not that the op intended it.

This could  be shortened by giving the isprime function a shorter name: i=1:n;p=@isprime;i(p(i)&p(i+6))

J, 34 33 31 32 39 37 characters
s=.[:(,.-&6)[:I.1([:*/p:)"1 i.,.6-~i.

Lost a character keeping both primes below the limit...and another 7 declaring a function.
Usage:
   s 100
11  5
13  7
17 11
19 13
23 17
29 23
37 31
43 37
47 41
53 47
59 53
67 61
73 67
79 73
89 83

Edit
Seems like a lot of the new answers are not creating functions, taking input or limiting both numbers in the pair to be below n - if I ignore those restrictions too I can get down to 28 characters:
(,.6&+)I.*/"1[1 p:(i.,.6+i.)

Mathematica, 35
{#,#+6}&~Array~#~Cases~{__?PrimeQ}&

GolfScript, 32 characters
~),2>{:P{(.P\%}do(!},:L{6+L?)},p

Since the output format was not specified, the code above will print the lower prime of each pair. Thus a number x is included if x and x+6 are both prime and both are below n. Input is given as single number on STDIN.
> 150
[5 7 11 13 17 23 31 37 41 47 53 61 67 73 83 97 101 103 107 131]

I think you should print both primes. It's a part of the task.

@ugoren The task was changed after I submitted my version. I'll try and add that to my version soon.

Yes, your answer matches the original task.

Python 2, 137 132 126 122 118
f=lambda x:not[y for y in range(2,x)if x%y==0]
i=30
print [(x,y)for x in range(i)for y in range(i)if f(x)&f(y)&x-6==y]

Try it online!
Using list comprehensions, as well as the fact that [] = False
f(x) actually returns all the factors of x, and you can then work out prime-ness from that.

You can turn f(x) into f=lambda x:not[y for y in range(2,x)if x%y==0] to save a few characters. You can also reduce the ifs at the end of your list comprehension with f(x)&f(y)&(x-6==y).

@beary605 I don't really know a lot about lamdas (well, I know nothing), so I'll look in to that, but yes, anda not ifs.

A lambda is an anonymous function which returns a value. a=lambda x,y,z:(value here) is the same as def a(x,y,z):return (value here).

Awesome, I seem to get the hang. Updated. Thanks!

Python (93 90 99 95)
Yay for quick and dirty isprime functions!
a=lambda x:all(x%i for i in range(2,x));b=2
while b<input():
 b+=1
 if a(b)&a(b+6):print b,b+6

1 instead of True will save you 3 characters...

Why do I keep missing that? Fixed.

You don't get a limit parameter. Also, [] in all() isn't needed (at least in Python 2.7).

Wow, really? Cool! I will implement the parameter.

I don't know why you subtract 1 from x, but you can remove that for 2 characters. Then you can replace the while loop with a for loops from 2 to input()+1 for another 2 characters.

K3 / Kona, 45
{a@&6=(-).'a:,/a,\:/:a:&{(x>1)&&/x!'2_!x}'!x}

.
{a@&6=(-).'a:,/a,\:/:a:&{(x>1)&&/x!'2_!x}'!x}100
(11 5
 13 7
 17 11
 19 13
 23 17
 29 23
 37 31
 43 37
 47 41
 53 47
 59 53
 67 61
 73 67
 79 73
 89 83)

And the same solution in the current incarnation of K which is identical to the K3 solution except for the fact that it does not have an inbuilt mod operator, which adds about 14 chars for 59
{a@&6=(-).'a:,/a,\:/:a:&{(x>1)&&/{x-y*x div y}[x;2_!x]}'!x}

C, 102 99 95 chars
Returning an array in C is something you try to avoid. So the function s gets the limit n and a pointer to an array of integers, and fills it with the data. Each pair of sexy primes is placed in two positions in the array. So o[0]=5, o[1]=11, o[2]=7, o[3]=13. The function assumes the array is large enough.
x=7,l;
p(){
    return++l>=x/2||x*(x-6)%l&&p();
}
s(int n,int*o){
    for(;l=++x<=n;)p()?*o++=x-6,*o++=x:0;
}

x86-Assembly (78 Bytes)
This example uses Intel syntax. Besides, here the fastcall or register calling convention is used (the latter from 32-bit Delphi), so the parameter is in ecx. I also introduce a second parameter that points to a free space for the result and is saved in edx. A function for allocating memory space would be specific to the operating system and a transfer via the stack would be problematic, so I chose this option.
listSexy:
   mov   ebp, esp      ; 89E5    Save initial esp
   mov   edi, edx      ; 89D7    Save second parameter in edx

   ; Part One: Save all prime numbers from 3 to the limit on the stack
   ; (This takes 32 Bytes)
   xor   eax, eax      ; 31C0    set eax = 1 (shorter than mov eax, 1)
   inc   eax           ; 40
checkComplete:
   add   eax, 2        ; 83C002  Go to next possible number (first is 3)
   cmp   eax, ecx      ; 39C8    Has the limit, i.e. the parameter, been skipped?
   jae   partTwo       ; 7316
   mov   ebx, esp      ; 89E3    Check it against all previous prime numbers
checkNext:             ;         which are stored between ebp and esp
   cdq                 ; 99      Clear edx for the later division
   push  eax           ; 50      Put the number on the stack
   cmp   ebx, ebp      ; 39E5    Has the check already completed?
   je    partTwo       ; 74F1    The comfirmed prime number remains on stack
   mov   esi, [ebx]    ; 8B33    Load a previous prime
   div   esi           ; F7F6
   pop   eax           ; 58
   test  edx, edx      ; 85D2    Is esi a divider?
   je    checkComplete ; 74E8
   add   ebx, 4        ; 83C304  Let ebx point to the next possible divisor
   jmp   checkNext     ; EBEC

   ; Part Zwo: Check all prime numbers if they are sexy primes
   ; (This takes 39 Bytes)
partTwo:
   mov   ebx, ebp      ; 89E5    Start with the first prime number, i.e. 3
NextPrime:
   sub   ebx, 4        ; 83EB04  Let ebx point to the next prime number
   cmp   ebx, esp      ; 39E3    Has the last number been reached? It cant be sexy,
                       ;         since it has no successors here
   jmp   Finished      ; 761E
   mov   edx, ebx      ; 89DA    Check all successors up to a distance of 6
   mov   eax, [ebx]    ; 8B03    eax is the prime number whose successors are checked
   add   eax, 6        ; 83C006
GoFurther:
   sub   edx, 4        ; 83EA04
   cmp   eax, [edx]    ; 8B02
   jb    NextPrime     ; 72EB    If the successor is too large, x can no longer be sexy
   ja    GoFurther     ; 77F7    If the successor is too small, take the next one
   mov   eax, [ebx]    ; 8B03    Load eax again (shorter than sub eax, 6)
   mov   ecx, [edx]    ; 8B0A    Load the successor which makes eax a sexy prime
   mov   [edi], eax    ; 8907    Store both in their intended place
   mov   [edi+4], ecx  ; 894F04
   add   edi, 8        ; 83C708
   jmp   NextPrime     ; EBDB

Finished:
   mov   esp, ebp      ; 89EC    Restore stack
   ret                 ; C3

The opcodes (and thus the size of the instruction) are given in the comment. The function can be called from C with, for example
int n = 100;
int resultList[50] = { };
listSexy(n, resultList);

The result list should be initialized with zero, since no final null byte sequence or similar is written into.
Online working example: http://tpcg.io/mEPb1Wy9

Welcome to the site! I'm not too familiar with Assembly, but I just wanted to make sure that your program follows the standard allowed input/output methods? It seems as though it does, but the snippet of C code is making me unsure. Furthermore, make sure to take a look at TryItOnline to see if any of the languages included can run your program, so that others can verify and help improve your answer

@cairdcoinheringaahing Thanks for your comment, I added a corresponding link and was able to fix a few typing errors too. From your link of the allowed input/output methods, however, I do not quite understand. My example provides a function, memory space for the return value is passed as a parameter at function call.

As I said, I‘m not very familiar with Assembly, so I can’t pass judgement on it’s validity. You can ask in our Chatroom, TNB, and I‘m sure someone more knowledgeable could answer

05AB1E, 7 bytes
ÅPãʒÆ7+

Try it online or verify a few more test cases.
Explanation:
ÅP       # Push a list of primes smaller than or equal to the (implicit) input-integer
  ã      # Create all possible pairs by taking the cartesian product with itself
         # (which will include inverted duplicates - i.e. both [5,11] and [11,5])
   ʒ     # Filter this list of pairs [a,b] by:
    Æ    #  Reduce it by subtracting: a-b
     7+  #  Add 7
         #  (only 1 is truthy in 05AB1E, so this will keep pairs that satisfy a-b+7==1)
         # (after which the resulting list of pairs is output implicitly)

Brachylog, 12 10 bytes
-2 thanks to @Fatalize
≥Iṗ-₆ṗ;I≜ᶠ

Try it online!
How it works
≥Iṗ-₆ṗ;I≜ᶠ
         ᶠ find all …
        ≜   force number-finding of constraints that fulfill …
             (strictly not necessary, but otherwise constraints will be returned)
≥             any number less than the input
 I            assign it to I
  ṗ           must be prime
   -₆ṗ        minus 6 must also be prime
      ;I      append I again (so we have [I-6,I])

You can use findall directly on the labelling predicate, to save 2 bytes: ≥Iṗ-₆ṗ;I≜ᶠ

Ruby, 99 88 86 84 82 78
f=->x{(9..x).map{|n|[n-6,n]if[n,n-6].all?{|t|(2...t).all?{|m|t%m>0}}}.compact}

Sample output:
[[5, 11], [7, 13], [11, 17], [13, 19], [17, 23], [23, 29], [31, 37], [37, 43], [41, 47], [47, 53], [53, 59], [61, 67], [67, 73], [73, 79], [83, 89]]

Perl: 73 char
sub p{(1x$_[0])!~/^(11+?)\1+$/}map{$x=$_+6;p($_)&&p($x)&&say"$_,$x"}2..<>

usage:
echo 30 | perl -E 'sub p{(1x$_[0])!~/^(11+?)\1+$/}map{$x=$_+6;p($_)&&p($x)&&say"$_,$x"}2..<>'

output:
5,11
7,13
11,17
13,19
17,23
23,29

Nice sulution with the regex. You can even shorten by 3 bytes: sub p{(1x$_[0])!~/^(11+?)\1+$/}map{p($_)&&p($_+6)&&say"$_,",$_+6}2..<>

Octave 39
Modified my MATLAB answer to comply with the new (annoying) rules. n is your value.
p=@isprime;i=1:n;[j=i(p(i)&p(i+6));j+6]

Can be tested here

R, 83 characters
f=function(n){library(gmp);p=isprime;for(i in 1:n)if(p(i)&p(i+6)){print(c(i,i+6))}}

Usage:
f(150)

Ruby 75 74
The new version uses Artem Ice's prime test method:
z=->x{(9..x).map{|i|[i-6,i]}.select{|a|a.all?{|r|(2...r).all?{|m|r%m>0}}}}

Online test: http://ideone.com/yaOdn

JavaScript (140 113 Characters)
t=(i,n)=>{for(n=i;n%--i;);return 1==i};s=(n,p)=>{for(p=[],i=2;i<n-6;i++)if(t(i)&&t(i+6))p.push([i,i+6]);return p}
Try s(30).
Updated to use the shorter primality test from here, and to use the new arrow notation.
Old version (140 characters):
function t(n,i){for(i=2;i<n;i++)if(!(n%i))return!1;return!0}function s(n,p){for(p=[],i=2;i<n-6;i++)if(t(i)&&t(i+6))p.push([i,i+6]);return p}

J, 25 chars
(#~*/"1@p:~&1)(,+&6)"0 i.

i.n creates a range of [0,n)
(,+&6)"0 takes each integer n in the list and makes a pair n, n+6
(#~ condition) is basically a filter, and the condition in this case, */"1@p:~&1, just checks if a pair is composed solely of primes.

C# (279 characters)
Basically, it's Saumil's solution with a couple of tweaks. I don't have enough any reputation for commenting though, so...
using System;namespace X{public class P{static int l=100;static void Main(){F(0);}static bool I(int n){bool b=1>0;if(n==1){b=1<0;}for(int i=2;i<n;++i){if(n%i==0){b=1<0;break;}}return b;}static void F(int p){if((p+6)<=l){if(I(p+6)&&I(p)){Console.WriteLine(p+6+","+p);}F(p+1);}}}}

Output:
11,5
13,7
17,11
19,13
23,17
29,23
37,31
43,37
47,41
53,47
59,53
67,61
73,67
79,73
89,83

05AB1E, 10 bytes
Outputs in reversed order, because the K3 answer also seems to do that.
LεD6-‚}ʒpP

Try it online!
Explanation
L           Length range
 ε          Map:
  D             Duplicate
   6-           Minus 6
     ‚          Pair
      }         Reverse the pair
       ʒ    Filter:
        p       Is_prime
         P      in both items

JavaScript (V8), 104 75 bytes
-29 bytes thanks to @emanresuA
g=x=>--x>6&&g(x,(f=(n,t=2)=>t<n?n%t&&f(n,t+1):n>1)(x)*f(x-6)&&print(x-6,x))

Try it online!

102

98 with a for loop

81 with a different output format

@emanresuA You might want to write a separate answer, since those are some major golfs.

Nah, you can have it. (75)

Jelly, 9 bytes
Rż+¥6ẒẠ$Ƈ

Try it online!
How it works
Rż+¥6ẒẠ$Ƈ - Main link. Takes N on the left
R         - Range; R = [1, 2, ..., N]
   ¥6     - Previous 2 links as a dyad f(R, 6):
  +       -   Add 6 to each element in R
 ż        -   Zip together
       $Ƈ - Keep those pairs for which the following is true:
      Ạ   -   Are all elements...
     Ẓ    -   ...prime?

Excel, 131 bytes
=LET(x,SEQUENCE(A1),y,TRANSPOSE(x),z,x*(MMULT((MOD(x,y)=0)*1,x^0)=2),a,IFERROR(INDEX(z,x+{0,6}),),FILTER(a,MMULT(SIGN(a),{1;1})=2))

Link to Spreadsheet
Explanation

=LET( allows defined names within formulas.
x,SEQUENCE(A1), x = 1..A1 listed vertically.
y,TRANSPOSE(x), y = 1..A1 listed horizontally.
(MOD(x,y)=0)*1 creates a matrix this is 1 if x mod y = 0 and 0 otherwise.
MMULT(~,x^0) sums the elements of each row with matrix multiplication. x^0 is a vertical matrix of 1s.
z,x*(~=2), if the sum = 2 then x is prime and z=x else z=0.
,a,IFERROR(INDEX(z,x+{0,6}),), creates an array a where the first column is z and the second is z offset by 6 rows.
FILTER(a,MMULT(SIGN(a),{1;1})=2) returns the rows of a that have no zeros.

Mathematica - 69 48 chars
Assuming m has been assigned a value
p=PrimeQ;Cases[Range@m,n_/;p@n&&p[n+6]:>{n,n+6}]

C# 295
using System;using System.Linq;namespace K{class C{public static void Main(string[]a){Func<int,bool>p=i=>Enumerable.Range(2,i-3).All(x=>i%x>0);Console.WriteLine("["+String.Join(",",Enumerable.Range(0,int.Parse(a[0])).Where(i=>i>9&&p(i)&&p(i-6)).Select(i=>"["+(i-6)+","+i+"]").ToArray())+"]");}}}

Online test: http://ideone.com/4PwTW (in this test I've replaced int.Parse(a[0]) with the actual int value, as I cannot supply command line arguments to programs running on ideone.com)

Scala (82)
def p(n:Int)=9 to n map(x=>List(x-6,x))filter(_.forall(l=>2 to l-1 forall(l%_>0)))

Sample output:
Vector(List(5, 11), List(7, 13), List(11, 17), List(13, 19), List(17, 23), List(23, 29), List(31, 37), List(37, 43), List(41, 47), List(47, 53), List(53, 59), List(61, 67), List(67, 73), List(73, 79), List(83, 89))

Factor 140
This language is fun and interesting. My first script.
:: i ( n -- ? )
n 1 - 2 [a,b] [ n swap mod 0 > ] all? ;
:: s ( n -- r r )
11 n [a,b] [ i ] filter [ 6 - ] map [ i ] filter dup [ 6 + ] map ;

Usage:
( scratchpad ) 100 f

--- Data stack:
V{ 5 7 11 13 17 23 31 37 41 47 53 61 67 73 83 }
V{ 11 13 17 19 23 29 37 43 47 53 59 67 73 79 89 }

PARI/GP  (62 characters)
f(a)=w=[];forprime(x=0,a,isprime(x+6)&w=concat(w,[[x,x+6]]));w

Example:
 (00:01) gp > f(a)=w=[];forprime(x=0,a,isprime(x+6)&w=concat(w,[[x,x+6]]));w
 (00:01) gp > f(30)
 %1 = [[5, 11], [7, 13], [11, 17], [13, 19], [17, 23], [23, 29]]

Haskell (65 chars)
p n=[(x,x+6)|x<-[3..n-6],all(\k->all((>0).mod k)[2..k-1])[x,x+6]]

The output:
Prelude> p 100
[(5,11),(7,13),(11,17),(13,19),(17,23),(23,29),(31,37),(37,43),(41,47),(47,53),(
53,59),(61,67),(67,73),(73,79),(83,89)]

About the MATLAB answer here:
(I spent all my rep on a bounty so can't comment just yet). Google says: " the Matlab's isprime function ... is based on the probabilistic Miller-Rabin". So it seems that the MATLAB entry should be disqualified.

R 85 81 characters
f=function(n){m=2:n;a=m[rowSums(!outer(m,m,`%%`))<2];cbind(b<-a[(a+6)%in%a],b+6)}

Example run:
f(50)
      [,1] [,2]
 [1,]    5   11
 [2,]    7   13
 [3,]   11   17
 [4,]   13   19
 [5,]   17   23
 [6,]   23   29
 [7,]   31   37
 [8,]   37   43
 [9,]   41   47

PHP, 106 bytes
function p($n){for($i=$n;--$i&&$n%$i;);return$i-1;}for(;++$i<$argv[1]-5;)p($i)|p($k=$i+6)?:print"$i,$k\n";

program prints pairs as n,n+6 delimited by linebreaks. Run with -r.
I modified my is_prime function (& saved a byte) so that it returns 0 for primes to golf on the Elvis.

CJam, 27 bytes
ri),{__6+_mp@mp&{pp}{;;}?}%

It prints pairs as two lines with one number each on then, largest to smallest. See the TIO for the example from the question.
Try it online
Explanation:
ri                              input an integer
  )                             increment
   ,{                    }%     iterate "m" from 0 to n-1
     __                         create two copies
       6+                       add 6
         _                      copy
          mp                    check if m+6 is prime
            @                   rotate so m is on top
             mp                 check if m is prime
               &                bitwise AND on two prime checks
                        ?       ternary if-else
                {pp}            if primes, print top two numbers
                    {;;}        otherwise, discard them

C# ( 321 303 290 characters )
using System;namespace X{public class P{ static int l=100;static void Main(){F(0);}static bool I(int n){bool b=true;if(n==1){b=false;}for(int i=2;i<n;++i){if(n%i==0){b=false;break;}}return b;}static void F(int p){if((p+6)<=l){int m=p+6;if(I(m)&&I(p)){Console.WriteLine(m+","+p);}F(p+1);}}}}
Output:
11,5
13,7
17,11
19,13
23,17
29,23
37,31
43,37
47,41
53,47
59,53
67,61
73,67
79,73
89,83

Welcome to CodeGolf! You can save some chars if you give the class and methods one-letter names (ex: class P instead of class Program).

Ruby, 61 bytes
->n{Prime.take_while{_1<=n}.map{[_1,_1+6]}.select{_2.prime?}}

Attempt This Online!

POSIX Shell Command Language + Utilities + seq + 4.1BSD factor, 101 bytes
seq 2 $1|factor|sed '/: .* /d;s/:.*//'>q
while read a;do grep -x $((a+6)) q&&echo $a;done<q|paste - -

seq generates integers in [2, specified], factor turns them into this format we all know and love:
2: 2
3: 3
4: 2 2
5: 5
6: 2 3

sed deletes lines with a space after the first colon-space (i.e. non-primes), then trims off everything after the colon.
For each prime a, we copy the prime equal to a+6 to the standard output stream, and if that succeeded, also write a, then we paste each pair of output lines together.
Any seq since its introduction in Version 8 AT&T UNIX works, and you can trivially replace it with a while at a cost of 42 bytes. Any factor since its introduction in Version 7 AT&T UNIX works (sans format quirks maybe, I'm not in the mood for reading PDP-11 assembly; if the format is space-less, then 4.1BSD probably has the right one).
Transcript of test cases:
$ cat d.sh; echo; wc -c d.sh
seq 2 $1|factor|sed '/: .* /d;s/:.*//'>q
while read a;do grep -x $((a+6)) q&&echo $a;done<q|paste - -
101 d.sh
$ ./d.sh 30
11      5
13      7
17      11
19      13
23      17
29      23

Herein an "array of arrays" is a set of lines containing tab-delimited fields.

Japt, 11 bytes
õ í7ôU)fÈej

Try it