text:
Langton's ant ASCII art.
Draw the path of Langton's ant.
Description

Squares on a plane are colored variously either black or white. We arbitrarily identify one square as the "ant". The ant can travel in any of the four cardinal directions at each step it takes. The ant moves according to the rules below:

At a white square, turn 90° right, flip the color of the square, move forward one unit
At a black square, turn 90° left, flip the color of the square, move forward one unit

Specifications

Input: an integer N between 0 and 725 (inclusive).
Output: a 17 by 17 grid representing the "path" of the ant as of step N.

Rules

The ant starts facing right (3 o' clock).
The ant starts at the center of the grid.
Use _#@ for white squares, black squares and the ant respectively.
The grid is initially completely white.
You may make either a complete program or a function on an interpreted language.
Input by stdin or argument.

Examples
Update: case's N = 450 output was wrong.
N = 0
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
________@________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________

N = 1
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
________#________
________@________
_________________
_________________
_________________
_________________
_________________
_________________
_________________

N = 450
_________________
_________________
___________##____
____##______##___
___#__##___##_#__
__###_#@#__#__#__
__#_#_#_#__#_#___
_____###___#_____
_____#___________
_____#__###______
___#_#_#__#_#_#__
__#__#_#____###__
__#_##__##___#___
___##______##____
____##___________
_________________
_________________

@Joey: yes "Complete program or function. Input by argument or stdin.", freestyle :)

@Joey: Sorry if that was not clear: you may either make a function on an interpreted language or a complete program. You may take input from stdin or provide it as an argument.

@Joey: Note that at step 1 the ant first turns right (now facing north) and then advances. Are you sure you are taking that into account?

@Joey: Yes, I meant south at the previous comment and you are right, the last example was for different N :-/ (Updated the examples section).

GolfScript - 67 chars
~17.'_'*n+*\153:|;{|/()[124^.2/6+:6.1&17*)\2&(*|+:|;]@++}*|/();'@'@

hallvabo's Python solution is the most similar to this, so I'll only describe the main differences.
The board is stored as a string instead of an array. This is so we can update a value on the board with less characters (as strings are always flat), and so getting it to the desired output format is easy.
The ant position is incremented by the formula ((d&1)*17+1)*((d&2)-1) (i.e. .1&17*)\2&(*), where d is the direction. We use the variable 6 so we can skip initialization.

Awww, now I feel like a GolfScript noob.

:6 - so hipster. I'd hate debugging your code :-)

Ruby 1.9, 104 characters
f=->z{l=[*[r=1]*17,2]*17;c=152;z.times{c+=r=(r*r>1?r/18:-r*18)*l[c]*=-1};l[c]=0;l.map{|a|putc"@_
#"[a]}}

Input via function argument.

(146 -> 142) Inlined m
(142 -> 140) Check for r*r>1 instead of r.abs>1
(142 -> 128) Use String#scan to generate the output. Changed a == to >
(128 -> 125) Removed obsolete variable
(125 -> 122) Replace String#tr with a conditional
(122 -> 122) Now generates the same output as the updated examples
(122 -> 111) Use ints instead of chars when generating the ant's path.
(111 -> 109) Reorder some expressions to save parentheses
(109 -> 108) Code is now a function
(108 -> 104) Print every character individually

Functions are permitted.

@Eelvex: Does the function have to return a string, or does it have to output it?

output.

Python, 123

n=input()
d=x=152
g=(17*[95]+[10])*17
while n:d+=g[x]/2;g[x]^=124;x+=(1,-18,-1,18)[d%4];n-=1
g[x]=64
print"%c"*306%tuple(g)

Just a slight reworking of my Python solution from http://golf.shinh.org/p.rb?Langtons+Ant.

Windows PowerShell, 119 118
for($p,$n,$g=144,+"$args"+,1*289;$n--){$d+=$g[$p]*=-1
$p+='B0@R'[$d%4]-65}$g[$p]=0
-join'@_#'[$g]-replace'.{17}',"$&
"

GolfScript 96 94 89
My favourite hate language is back with another bunch of of semi-readable sorta-bytecode.
89 version, I finally managed to integrate @ into the output loop.
~289[0:c]*145:b;{.b>\b<)!..c++(4%:c[1 17-1-17]=b+:b;@++}@*{{(b(:b!.++'_#@@'1/=\}17*n\}17*

94 version:
~306[0:c]*152:b;{.b<\b>(!..c++(4%:c[1 18-1-18]=b+:b;\++}@*{{('_#'1/=\}17*(;n\}17*].b<\b>(;'@'\

Commented:
               #Initialization.
~                  #Parse input.
306[0:c]*          #Make array of 306 0s, set c to 0 in the middle of that operation.
152:b;             #Set b to 152, remove 152 from the stack.
                   #b is a value for the ant's position, c for its rotation.

               #Run the algorithm.
{                  #Start of block.
    .b<\b>(        #Split the array at index b into before, after and value at b.
    !..            #Not the value and make 2 copies of it.
    c++            #Add the 2 copies to c.
    (4%:c          #Subtract 1, modulus by 4 and save the result to c.
    [1 18-1-18]=   #Define an array and take element number c.
    b+:b;          #Add b to the value, save result to b, remove result from stack.
    \++            #Reform the array.
}@*                #Switch the input to the top of the stack and run the block input times.

               #Convert array of 1s and 0s to the correct characters.
{                  #Start of block.
    {              #Start of block.
        ('_#'1/=   #Take the first array element, convert it to either '_' or '#'.
        \          #Switch the array to the top of the stack.
    }17*           #Execute block 17 times.
    (;n\           #Discard the 18th element of the line, write a lineshift.
}17*               #Execute block 17 times.

               #Insert the @.
]                  #Put everything in an array.
.b<\b>(            #Split the array at index b into before, after and value at b.
;'@'\              #Ditch the value at b, write a @ and shift it into place.

Edit, I might as well make a big version, here goes 59*59 and 10500 iterations:
~59:a.*[0:c]*1741:b;{.b>\b<)!..c++(4%:c[1 a-1-59]=b+:b;@++}@*{{(b(:b!.++'_#@@'1/=\}a*n\}a*

.
___________________________________________________________
___________________________________________________________
_________________________##__##____________________________
________________________#__@_###___________________________
_______________________###__#_#_#__________________________
_______________________#####_#__##_________________________
________________________#___##_##_#________________________
_________________________###___#__##_______________________
__________________________#___##_##_#______________________
___________________________###___#__##_____________________
____________________________#___##_##_#__##________________
_____________________________###___#__##__##_______________
______________________________#___##_##__##___#____________
________________________####___###___#___#__###____________
_______________________#____#___#___##_####___#____________
______________________###____#___#_#______#_##_#___________
______________________###____#_##_____#_##__#_##___________
_______________________#____#___##_#_#_____##______________
_______________________#_#______#_#####__#___#_____________
______________________#___#####__________##_######_________
______________________###__##__#_##_#_#_#___##_#_##________
____________________##__#_#######_#___#__###____##_#_______
___________________#__#__######_##___#__#_##___#___#_______
__________________#____#_#_##_#__######_#######___#________
__________________#_####_##_#_####____##__##_#_##_#________
___________________#____####___#__#_######_##____###_______
______________________#___#_##_#_###_#__##__##___###_______
_________________________#######____#__##_##_#_____#_______
_________________####__##_##__####_##_##_##__#_____#_______
________________#____#_#___###_##_###____#_####____#_______
_______________###_______###_#_#_#####____#_#______#_______
_______________#_#___###_####_##_#___##_###_##_____#_______
_____________________##_##__####____####_#_#_#_____#_______
________________#____#__##___###__###_____###______#_______
________________##___##_###_####__#______###___##__#_______
________________##_#_####_____#___#__#_##_###_##___#_______
_______________####_##___##_####__#_#__#__#__###___#_______
_______________#_##_###__#_#_##_#_#_____#_#_____#_#________
___________________#_#__#____##_##__#_#__###_##____________
___________________##_#____#__#####_#____#____#__#_#_______
__________________#_##_#__#____##_##_#__###______###_______
________________#_#___#__#__#__#__###___##__##____#________
_______________###_#_#####_######_###_#######_#_##_________
_______________#_#_#____#####___##__#####_#####____________
_________________#__##___#______#__#_##__###_###___________
______________####___#####_#########___#_#_________________
_________##____#__#_____###_#_#___#_###__###_______________
________#__#__####_##___###_##___###_##_____##_____________
_______###____#_##_#_#####___#____#__#__##_###_____________
_______#_#####_#_#___##__##_____#____#___#__#______________
___________######_####__##_#___#__##__#_#_##_______________
_________##______#_###_##__####___#___###__________________
__________#__#_#####__#___#_##___#__#__#___________________
__________##_###_#######_____#_____#_##____________________
_________#_#__##_##______#___##____#_______________________
________#__#_####________###__##__#________________________
________#_##_###____________##__##_________________________
_________##________________________________________________
__________##_______________________________________________

PHP, 350 309 307 312 174 161 166 159 151 149 147 144 143
<?$p=144;while($i=$argv[1]--){$g[$p]=$a=2-$g[$p];$d+=--$a;$p+=(1-($d&2))*(1+16*($d&1));}while($i++<288)echo$i%17?$i!=$p?$g[$i]?"#": _:"@":"\n";

Ungolfed
$p = 144; // Set initial pointer

while($i = $argv[1]--){ // Ends at -1
    $g[$p] = $a = 2 - $g[$p]; // Either returns true (2) or false(0)

    $d += --$a; // Adds 1 (2-1) or removes 1 (0-1) from the direction

    $p += (1 - ($d & 2)) * (1 + 16 * ($d & 1));
}

while($i++ < 288)
    echo $i % 17? $i != $p? $g[$i]? "#" : @_ : "@" : "\n"; // Prints the correct character

350 -> 309: Various compression techniques with the for() loops, also updated to show correct output.
309 -> 307: Converted main for() loop to a while() loop.
307 -> 312: Forgot to change it to use argv.
312 -> 174: Recoded based on another answer.
174 -> 161: No longer defaults entire array.
161 -> 166: Argv wins again.
166 -> 159: No need to redefine argv[1].
159 -> 151: No longer defaults anything, PHP does it automatically.
151 -> 149: Removed a set of parenthesis, order of operations removes the need.
149 -> 147: Shortened the last for() loop, braces not needed.
147 -> 144: Last for() loop is now a while() loop.
144 -> 143: Used a temporary variable to save a character.

I see you used my grid & direction tricks, and that it removed 138 chars from your code, nice!

Delphi, 217
var g,a:PByte;i,d,Word;begin g:=AllocMem(306);a:=g+153;Read(i);for n:=1to i do begin a^:=2-a^;d:=d-1+a^;a:=a+(1-2and d)*(1+17*(1and d))end;a^:=1;for n:=1to 306do if n mod 18=0then WriteLn else Write('_@#'[1+g[n]])end.

The indented & commented code reads like this:
var
  g,a:PByte;
  i,d,n:Int32;
begin
  g:=AllocMem(306); // g: The grid is initially completely white. (size=18*17=306)
  // Assume 0=d: Ant start 'd'irection faces right (=0, see below)
  a:=g+153; // a: Ant position starts at the center of the grid (=8*18+9=153)
  Read(i);
  for n:=1to i do
  begin
    // Flip the color of the square;
    a^:=2-a^;
    // Turn 90° right if at an '_' space, 90° left otherwise;
    d:=d-1+a^;
    // Move one unit forward;
    //   For this, determine the step size, using the two least significant bits of d.
    //   This gives the following relation :
    //     00 = 0 =  90° = right =   1
    //     01 = 1 = 180° = down  =  18
    //     10 = 2 = 270° = left  = - 1
    //     11 = 3 =   0° = up    = -18
    //   (d and 2) gives 0 or 2, translate that to 1 or -1
    //   (d and 1) gives 0 or 1, translate that to 1 or 18
    //   Multiply the two to get an offset 1, 18, -1 or -18 :
    a:=a+(1-2and d)*(1+17*(1and d))
  end;
  // Place the ant and print the grid :
  a^:=1; // 0 > '_', 1='@', 2 > '#'
  for i:=1to 306do
    if i mod 18=0then // we insert & abuse column 0 for newlines only (saves a begin+end pair)
      WriteLn
    else
      Write('_@#'[1+g[i]])
end.

Input:
450

Output :
_________________
_________________
___________##____
____##______##___
___#__##___##_#__
__###_#@#__#__#__
__#_#_#_#__#_#___
_____###___#_____
_____#___________
_____#__###______
___#_#_#__#_#_#__
__#__#_#____###__
__#_##__##___#___
___##______##____
____##___________
_________________
_________________

@Patrick: the example was wrong, please check the updates. (and it seems that you output step 451 :) ).

@Eelvex : Thanks. I fixed the case 'N=0' at a cost of 4 chars... now I gotta win them back again! ;-)

@Eelvex : PS: No +1 for spotting your error 3 hours ago with just a humble remark it could be my fault? ;)

@Patrick: I was waiting for <200 but ok... :)

@Eelvex: LOL, getting there... (down to 238 already)

To get the 4 chars back, you can change int32-->word,  (1-d and 2)-->(1-2and d) , (d and 1)-->(1and d) and Write(^J) -->WriteLn

C, 166 162
Here a translation of my Delphi-approach to C, showing off how compact C can be. I borrowed the conditional newline trick from fR0DDY (thanks mate!) :
g[289]={0},a=144,d,i,N;main(){scanf("%d",&N);while(N--)g[a]=2-g[a],d+=g[a]-1,a+=(1-(d&2))*(1+d%2*16);for(g[a]=1;i<289;)printf("%s%c",i++%17?"":"\n","_@#"[g[i]]);}

The indented, commented version looks like this :
g[289]={0}, // g: The grid is initially completely white. (size=17*17=289)
a=144, // a: Ant position starts at the center of the grid (=8*17+8=144)
d, // Assume 0=d: Ant start 'd'irection faces right (=0, see below)
i,
N;
main(){
  scanf("%d",&N);
  while(N--)
    // Flip the color of the square:
    g[a]=2-g[a],
    // Turn 90° right if at an '_' space, 90° left otherwise :
    d+=g[a]-1,
    // Move one unit forward;
    //   For this, determine the step size, using the two least significant bits of d.
    //   This gives the following relation :
    //     00 = 0 =  90° = right =   1
    //     01 = 1 = 180° = down  =  17
    //     10 = 2 = 270° = left  = - 1
    //     11 = 3 =   0° = up    = -17
    //   (d and 2) gives 0 or 2, translate that to 1 or -1
    //   (d and 1) gives 0 or 1, translate that to 1 or 17
    //   Multiply the two to get an offset 1, 17, -1 or -17 :
    a+=(1-(d&2))*(1+d%2*16);
  // Place the ant and print the grid :
  for(g[a]=1;i<289;)
    printf("%s%c",i++%17?"":"\n","_@#"[g[i]]); // 0 > '_', 1='@', 2 > '#'
}

+1. I like the tricks "_@#"[g[i]] and a+=(1-(d&2))*(1+(16*(d&1)))

(1+d%2*16) saves a few chars.

@Nabb: Indeed, that saves 4 characters, thanks for the suggestion!

147 bytes

C 195 Characters
x=144,T,p=1,i,N[289]={0},a[]={-17,1,17,-1};c(t){p=(p+t+4)%4;x+=a[p];}main(){scanf("%d",&T);while(T--)N[x]=(N[x]+1)%2,c(N[x]?1:-1);for(;i<289;i++)printf("%s%c",i%17?"":"\n",i-x?N[i]?'#':'_':'@');}

http://www.ideone.com/Dw3xW
I get this for 725.
_________________
_________________
___________##____
____##______##___
___#___##__##_#__
__###____#_#__#__
__#_#_#__#_#_#___
______###____#__@
_______###__#__#_
_____#_#____#___#
___#_#_#_##____#_
__#__#_#_#_#_###_
__#_##_#_____####
___##_#____#_####
____###___####_#_
_______#__#__##__
________####_____

Using p+=t+4;x+=a[p%4]; instead of p=(p+t+4)%4;x+=a[p]; saves three characters.

146 bytes

sed, 481 chars
#n
1{s/.*/_________________/;h;H;H;H;G;G;G;G;s/^\(.\{152\}\)_/\1@/;s/$/;r/;ta;};x;:a;/;r/br;/;d/bd;/;l/bl;/;u/bu;:w;y/rdlu/dlur/;bz;:b;y/rdlu/urdl/;bz;:r;s/@\(.\{17\}\)_/#\1@/;tw;s/@\(.\{17\}\)#/#\1!/;tw;s/_\(.\{17\}\)!/@\1_/;tb;s/#\(.\{17\}\)!/!\1_/;tb;:d;s/_@/@#/;tw;s/#@/!#/;tw;s/!_/_@/;tb;s/!#/_!/;tb;:l;s/_\(.\{17\}\)@/@\1#/;tw;s/#\(.\{17\}\)@/!\1#/;tw;s/!\(.\{17\}\)_/_\1@/;tb;s/!\(.\{17\}\)#/_\1!/;tb;:u;s/@_/#@/;tw;s/@#/#!/;tw;s/_!/@_/;tb;s/#!/!_/;tb;:z;h;${s/!/@/;s/;.//p}

May be reduced to 478 chars by removing first line and running with -n
Requires N lines for input, eg. when run as
seq 450 | sed -f ant.sed

outputs:
_________________
_________________
___________##____
____##______##___
___#__##___##_#__
__###_#@#__#__#__
__#_#_#_#__#_#___
_____###___#_____
_____#___________
_____#__###______
___#_#_#__#_#_#__
__#__#_#____###__
__#_##__##___#___
___##______##____
____##___________
_________________
_________________

Perl, 110 characters
$p=144;$p+=(1,-17,-1,17)[($d+=($f[$p]^=2)+1)%4]for 1..<>;$f[$p]=1;print$_%17?'':$/,qw(_ @ #)[$f[$_]]for 0..288

Number is read from the first line of STDIN. Rest of input is ignored.
Slightly more readable:
$p=144;
$p += (1,-17,-1,17)[($d+=($f[$p]^=2)+1) % 4] for 1..<>;
$f[$p]=1;
print $_%17 ? '' : $/, qw(_ @ #)[$f[$_]] for 0..288

Edits

(112 → 111) No need to update $d with the modulo-4 value.
(111 → 110) Can now inline the $d increment

Addendum (109 characters)
We can have it one character shorter if you’re happy to have the special case of N=0 fail (it doesn’t output the @ character for the ant). All other inputs work correctly:
$p+=(1,-17,-1,17)[($d+=($f{$p+0}^=2)+1)%4]for 1..<>;$f{$p}=1;print$_%17-9?'':$/,qw(_ @ #)[$f{$_}]for-144..144

The differences are that we now use %f instead of @f so we can use negative indices, and we iterate from -144..144 instead of 0..288. It saves having to initialise $p.

><>, 122 bytes
At the risk of a little thread necromancy, I thought writing an answer in ><> would be an interesting challenge...
1&f8r\
1-:?!\r:@@:@$:@@:@g:2*1+&+4%:&}1$-@p{:3$-5gaa*-$@+@5gaa*-+r
2}p70\~
a7+=?\:@@:@g4+5go$1+:
o053.>~1+:64*=?;a
dedc_#@

This program expects the number of steps to compute to be present on the stack before execution.

Mathematica, 94 chars
a@_=d=1;a@Nest[#+(d*=(a@#*=-1)I)&,9-9I,Input[]]=0;Grid@Array["@"[_,"#"][[a[#2-# I]]]&,17{1,1}]

APL(Dyalog Unicode), 108 bytes SBCS
{'@'@(⊂9 11○⊃⍵)⊢3⊃⍵}{p s g←⍵⋄(p+s)(s←s×0j1×¯1 1['#_'⍳g[x]])(('_#'~g[x])@(x←⊂9 11○p)⊢g)}⍣⎕⊢9J9 0J1(17 17⍴'_')

Try it on APLgolf!, Alternate version
A tradfn submission which takes a single number as input.

brainfuck, 5040 4562 4390 bytes
,>,>,>++++++[->++++++++<]>[<<-<-<->>>>-]>++++++++>++++++++<<<<[>+>+<<-]>[<+>-]<<[>>+>+<<<-]>>[<<+>>-]<<<[>>>+>+<<<<-]>>>[<<<+>>>-]>[<+>[-]]<[>>>>+>+<<<<<-]>>>>>[<<<<<+>>>>>-]<[-<<<<<[>>>>>+>-<<<<<<-]>>>>>-[<<<<<+>>>>>-]+>[<->[-]]<[-<<<<<[-]+++++++++<[>>>>>>+>-<<<<<<<-]>>>>>>-[<<<<<<+>>>>>>-]+>[<->[-]]<[<<<<<<++++++++++<->>>>>>>-]]<<<<[>>>>+<<<<-]<[>+>>>>>-<<<<<<-]>[<+>-]<<[>>+>>>>>-<<<<<<<-]>>[<<+>>-]<<<[>>>+>>>>>-<<<<<<<<-]>>>[<<<+>>>-]>>>>[<<<<+>>>>-]+>[<->[-]]<[<<<<->>>>-]<[>+++++++++++++++++>+<<-]>>[<<+>>-]<<<[>>+>+<<<-]>>>[<<<+>>>-]<[>>[-]+<[>+<-]<-[>+<-]>]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[<<+>>-]<[<[<+>-]>-[<+>-]<]+<[>-<<<<->>>-]>[<<<<+>[>>>>+>+<<<<<-]>>>>>[<<<<<+>>>>>-]<<<<[>>>+++++++++++++++++>+<<<<-]>>>>[<<<<+>>>>-]<[>>>[-]<[>+<-]<+[>+<-]<-[>+<-]>]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[-[<+>-]<]<<-]<+<<<[>>>>+<<<<-]>>>>>++++<[->-[>+>>]>[+[<+>-]>+>>]<<<<<]>>[<<+<<<<+>>>>>>-]<<[-[-[<<->->-]<[<<->>-]>]<[<+>-]>]<[<<+>>-]<<<<[>>>>+>+<<<<<-]>>>>>[<<<<<+>>>>>-]<]>+[[-]>+[[-]<<[>>+>-<<<-]>>[<<+>>-]<<<[>>>+>+<<<<-]>>>[<<<+>>>-]+>[<->[-]]<<[>>+>-<<<-]>>[<<+>>-]<<<<<[>>>>>+>+<<<<<<-]>>>>>[<<<<<+>>>>>-]+>[<->[-]]<<[->[>+<-]<]>>[<<+>>-]<[-]+<[->+++++++[->++++++++<]>.<<]>[-<<<[>>>+>+++++++++++++++++<<<<-]>>>[<<<+>>>-]<<[>>+>+<<<-]>>[<<+>>-]>[>+[>+<-]<-[>+<-]>]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<-]>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>[<<+>>-]<[<[<+>-]>-[<+>-]<]+<[---[>--<+++++++]>--.[-]<]>[--[>++<-----]>-------.[-]<]<<]<<[>+>+<<-]>>+[<<+>>-]<----------------]++++++++++.[-]<[-]<[>+>+<<-]>>+[<<+>>-]<----------------]

Try it online!
Input is zero padded. So for 5 iterations you type 005.


text:
Floating point addition, without floats!
Your task is to write a program, in any language, that adds two floating point numbers together WITHOUT using any fractional or floating point maths. Integer maths is allowed.
Format
The format for the numbers are strings containing 1's and 0's which represent the binary value of a IEEE 754 32-bit float. For example the number 2.54 would be represented by the string "01000000001000101000111101011100".
Goal
You program should input two numbers in the above mentioned format, add them together, and output the result in the same format. The shortest answer in any language wins!
Rules
Absolutly no floating point, decimal, or any kind of non-integer maths functions are allowed.
You can assume that the input is clean (i.e. contains only 1's and 0's).
You can assume that the inputs are numbers, and not Inf, -Inf, or NaN or subnormal. However, if the result is greater than the max value or smaller than the min value, you should return Inf and -Inf respectively. A subnormal (denormal) result may be flushed to 0.
You do not have to handle rounding properly. Don't worry if your results are a few bits out.
Tests
To test your programs, you can convert between decimal and floating point binary numbers using this tool.
1000 + 0.5 = 1000.5
01000100011110100000000000000000 + 00111111000000000000000000000000 = 01000100011110100010000000000000

float.MaxValue + float.MaxValue = Infinity
01111111011111111111111111111111 + 01111111011111111111111111111111 = 01111111100000000000000000000000

321.123 + -123.321 = 197.802
01000011101000001000111110111110 + 11000010111101101010010001011010= 01000011010001011100110101010000

Good luck!

Python, 224 chars
This code converts a floating point input f to the integer f*2^150, does the addition using python native big integers, then converts back.
V=lambda x:((-1)**int(x[0])<<int(x[1:9],2))*int('1'+x[9:],2)
B=lambda x,n:B(x/2,n-1)+'01'[x&1]if n else''
def A(x,y):
 v=V(x)+V(y)
 s=e=0
 if v<0:s=1;v=-v
 while v>=1<<24:v/=2;e+=1
 if e>254:v=0
 return'%d'%s+B(e,8)+B(v,23)

J (172 characters)
Since IEEE 754 allows five rounding rules, I chose the "toward 0" rule. Here is my code:
b=:(_1&^)@".@{.*[:#.1x,("."0)@(9&}.),#.@:("."0)@}.@(9&{.)$0:
a=:b@[([:,(<&0)":"0@:,,@((8$2)&#:)@(-&24)@$@#:,}.@(24&{.)@#:@|)@(]`(**2x^278"_)@.((>&((2x^278)-2x^254))@|))@+b@]

The very same examples you give (but not exactly the same results because of the different rounding rule):
   '01000100011110100000000000000000' a '00111111000000000000000000000000'
01000100011110100010000000000000
   '01111111011111111111111111111111' a '01111111011111111111111111111111'
01111111100000000000000000000000
   '01000011101000001000111110111110' a '11000010111101101010010001011010'
01000011010001011100110101001111

source: Stack Exchange

license: 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/2.5/

sort: votes


text:
Arbitrary Base Conversion
Create a routine that takes an array of blocks in one numeric base system, and convert them to an array of blocks in another numeric base system.  Both the from and to systems are arbitrary and should be accepted as a parameter.  The input array can be an arbitrary length (If using a language where array lengths are not stored with the array, such as C, a length parameter should be passed to the function).
Here's how it should work:
fromArray = [1, 1]
fromBase = 256
toBase = 16
result = convertBase(fromArray, fromBase, toBase);

Which should return [0, 1, 0, 1] or possibly [1, 0, 1] (leading 0s are optional since they don't change the value of the answer).
Here are some test vectors:

Identity Test Vector
fromArray = [1, 2, 3, 4]
fromBase = 16
toBase = 16
result = [1, 2, 3, 4]

Trivial Test Vector
fromArray = [1, 0]
fromBase = 10
toBase = 100
result = [10]

Big Test Vector
fromArray = [41, 15, 156, 123, 254, 156, 141, 2, 24]
fromBase = 256
toBase = 16
result = [2, 9, 0, 15, 9, 12, 7, 11, 15, 14, 9, 12, 8, 13, 0, 2, 1, 8]

Really Big Test Vector
fromArray = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
fromBase = 2
toBase = 10
result = [1, 2, 3, 7, 9, 4, 0, 0, 3, 9, 2, 8, 5, 3, 8, 0, 2, 7, 4, 8, 9, 9, 1, 2, 4, 2, 2, 3]

Non-even Base Vector
fromArray = [41, 42, 43]
fromBase = 256
toBase = 36
result = [1, 21, 29, 22, 3]

Other criteria / rules:

All integer variables should fit within a standard 32 bit signed integer for all sane input ranges.
You may convert to an intermediary representation, as long as the intermediary is nothing more than an array of 32 bit signed integers.
Expect to handle bases from 2 through 256.  There isn't any need to support higher bases than that (but if you would like to, by all means).
Expect to handle input and output sizes at least up to 1000 elements.  A solution that scales to 2^32-1 elements would be better, but 1000 is just fine.
This isn't necessarily about having the shortest code that will meet these rules.  It's about having the cleanest and most elegant code.

Now, this isn't exactly trivial to do, so an answer that almost works might be accepted!

Does #1 mean we can't use a bigint type?

@Keith: Correct.  Only 32 bit integers.

You say "signed integer" but the examples are only for positive integers, so: do we have to handle negatives?

@Eelvex: I don't see a need to handle negatives.  If a negative is handled, it would be outside of the converter.

Are they always integer bases?

Python
# divides longnum src (in base src_base) by divisor
# returns a pair of (longnum dividend, remainder)
def divmod_long(src, src_base, divisor):
  dividend=[]
  remainder=0
  for d in src:
    (e, remainder) = divmod(d + remainder * src_base, divisor)
    if dividend or e: dividend += [e]
  return (dividend, remainder)

def convert(src, src_base, dst_base):
  result = []
  while src:
    (src, remainder) = divmod_long(src, src_base, dst_base)
    result = [remainder] + result
  return result

Thank you. I was looking for a routine like this. It took me a while to convert it to Javascript though. I'll probably golf it a little and post here for the fun of it.

Here's a Haskell solution
import Data.List
import Control.Monad

type Numeral = (Int, [Int])

swap              ::  (a,b) -> (b,a)
swap (x,y)        =   (y,x)

unfoldl           ::  (b -> Maybe (b,a)) -> b -> [a]
unfoldl f         =   reverse . unfoldr (fmap swap . f)

normalize         ::  Numeral -> Numeral
normalize (r,ds)  =   (r, dropWhile (==0) ds)

divModLongInt            ::  Numeral -> Int -> (Numeral,Int)
divModLongInt (r,dd) dv  =   let  divDigit c d = swap ((c*r+d) `divMod` dv)
                                  (remainder, quotient) = mapAccumR divDigit 0 (reverse dd)
                             in   (normalize (r,reverse quotient), remainder)

changeRadixLongInt       ::  Numeral -> Int -> Numeral
changeRadixLongInt n r'  =   (r', unfoldl produceDigit n)
  where  produceDigit  (_,[])   =  Nothing
         produceDigit  x        =  Just (divModLongInt x r')

changeRadix :: [Int] -> Int -> Int -> [Int]
changeRadix digits origBase newBase = snd $ changeRadixLongInt (origBase,digits) newBase

doLine line = let [(digits,rest0)] = reads line
                  [(origBase,rest1)] = reads rest0
                  [(newBase,rest2)] = reads rest1
              in show $ changeRadix digits origBase newBase

main = interact (unlines . map doLine . lines)

And running the tests from the question:
$ ./a.out
[1,2,3,4] 16 16
[1,2,3,4]
[1,0] 10 100
[10]
[41, 15, 156, 123, 254, 156, 141, 2, 24] 256 16
[2,9,0,15,9,12,7,11,15,14,9,12,8,13,0,2,1,8]
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] 2 10
[1,2,3,7,9,4,0,0,3,9,2,8,5,3,8,0,2,7,4,8,9,9,1,2,4,2,2,3]
[41, 42, 43] 256 36
[1,21,29,22,3]

Oh wow.  That's awesome!  Now, if only I could understand it :-)... (but that's my task now)...

R
Handles many thousands of elements* in less than a minute.
addb <- function(v1,v2,b) {
    ml <- max(length(v1),length(v2))
    v1 <- c(rep(0, ml-length(v1)),v1)
    v2 <- c(rep(0, ml-length(v2)),v2)
    v1 = v1 + v2
    resm = v1%%b
    resd = c(floor(v1/b),0)
    while (any(resd != 0)) {
        v1 = c(0,resm) + resd
        resm = v1%%b
        resd = c(floor(v1/b),0)
    }
    while (v1[1] == 0) v1 = v1[-1]
    return(v1)
}

redb <- function(v,b) {
    return (addb(v,0,b))
}

mm = rbind(1)

mulmat <- function(fromb, tob, n) {
    if (dim(mm)[2] >= n) return(mm)
    if (n == 1) return(1)
    newr = addb(mulmat(fromb,tob,n-1) %*% rep(fromb-1,n-1), 1, tob)
    newm = mulmat(fromb,tob,n-1)
    while (is.null(dim(newm)) || dim(newm)[1] < length(newr)) newm = rbind(0,newm)
    mm <<-  cbind(newr, newm)
    return(mm)
}

dothelocomotion <- function(fromBase, toBase, v) {
    mm  <<- rbind(1)
    return(redb(mulmat(fromBase, toBase, length(v)) %*% v, toBase))
}

* for >500 elements you have to raise the default recursion level or do not reset the mm matrix on dothelocomotion()
Examples:
v1 = c(41, 15, 156, 123, 254, 156, 141, 2, 24)
dothelocomotion(256,16,v1)
2  9  0 15  9 12  7 11 15 14  9 12  8 13  0  2  1  8

dothelocomotion(256,36,c(41,42,43))
1 21 29 22  3

dothelocomotion(2,10, rep(1,90))
1 2 3 7 9 4 0 0 3 9 2 8 5 3 8 0 2 7 4 8 9 9 1 2 4 2 2 3

A less obfuscated and quicker JavaScript version:
function convert (number, src_base, dst_base)
{
    var res = [];
    var quotient;
    var remainder;

    while (number.length)
    {
        // divide successive powers of dst_base
        quotient = [];
        remainder = 0;
        var len = number.length;
        for (var i = 0 ; i != len ; i++)
        {
            var accumulator = number[i] + remainder * src_base;
            var digit = accumulator / dst_base | 0; // rounding faster than Math.floor
            remainder = accumulator % dst_base;
            if (quotient.length || digit) quotient.push(digit);
        }

        // the remainder of current division is the next rightmost digit
        res.unshift(remainder);

        // rinse and repeat with next power of dst_base
        number = quotient;
    }

    return res;
}

Computation time grows as o(number of digits2).
Not very efficient for large numbers.
Specialized versions line base64 encoding take advantage of base ratios to speed up the computations.

doing god's work son

Javascript
Thank you Keith Randall for your Python answer. I was struggling with the minutiae of my solution and ended up copying your logic. If anyone is awarding a vote to this solution because it works then please also give a vote to Keith's solution.
function convert(src,fb,tb){
  var res=[]
  while(src.length > 0){
    var a=(function(src){
      var d=[];var rem=0
      for each (var i in src){
        var c=i+rem*fb
        var e=Math.floor(c/tb)
        rem=c%tb
        d.length||e?d.push(e):0
      }
      return[d,rem]
    }).call(this,src)
    src=a[0]
    var rem=a[1]
    res.unshift(rem)
  }
  return res
}

Tests
console.log(convert([1, 2, 3, 4], 16, 16))
console.log(convert([1, 0], 10, 100))
console.log(convert([41, 15, 156, 123, 254, 156, 141, 2, 24], 256, 16))
console.log(convert([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 2, 10))
console.log(convert([41, 42, 43], 256, 36))

/*
Produces:
[1, 2, 3, 4]
[10]
[2, 9, 0, 15, 9, 12, 7, 11, 15, 14, 9, 12, 8, 13, 0, 2, 1, 8]
[1, 2, 3, 7, 9, 4, 0, 0, 3, 9, 2, 8, 5, 3, 8, 0, 2, 7, 4, 8, 9, 9, 1, 2, 4, 2, 2, 3]
[1, 21, 29, 22, 3]
*/

This could probably be shrunk a lot, but I actually want to use it for a little side project. So I have kept it readable (somewhat) and tried to keep variables in check.

how is it javascript? for each?

No variable names above 3 characters, deprecated for each statement and eye-watering constructs like d.length||e?d.push(e):0... Is this an obfuscated code challenge or something? You could write the same thing with an understandable syntax and better performances.

@kuroineko This is code golf. What were you expecting? Clean, readable code using up-to-date standards? I never claimed my answer was perfect and I would certainly not use it as is in a production project.

Well I actually needed this algorithm in JavaScript for some reason, and I had to rewrite it from scratch, taking the python solution as a base. I appreciate your contribution, but for practical purposes it was hardly useable at all IMHO.

Mathematica
No variables defined, any input accepted as long as it fits in memory.
f[i_, sb_, db_] := IntegerDigits[FromDigits[i, sb], db];

Test drive:
f[{1,2,3,4},16,16]
f[{1,0},10,100]
f[{41,15,156,123,254,156,141,2,24},256,16]
f[{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},2,10]
f[{41,42,43},256,36]

Out
{1,2,3,4}
{10}
{2,9,0,15,9,12,7,11,15,14,9,12,8,13,0,2,1,8}
{1,2,3 7,9,4,0,0,3,9,2,8,5,3,8,0,2,7,4,8,9,9,1,2,4,2,2,3}
{1,21,29,22,3}

Scala:
def toDecimal (li: List[Int], base: Int) : BigInt = li match {
  case Nil => BigInt (0)
  case x :: xs => BigInt (x % base) + (BigInt (base) * toDecimal (xs, base)) }

def fromDecimal (dec: BigInt, base: Int) : List[Int] =
  if (dec==0L) Nil else (dec % base).toInt :: fromDecimal (dec/base, base)

def x2y (value: List[Int], from: Int, to: Int) =
  fromDecimal (toDecimal (value.reverse, from), to).reverse

Testcode with tests:
def test (li: List[Int], from: Int, to: Int, s: String) = {
 val erg= "" + x2y (li, from, to)
 if (! erg.equals (s))
   println ("2dec: " + toDecimal (li, from) + "\n\terg: " + erg + "\n\texp: " + s)
}

 test (List (1, 2, 3, 4), 16, 16, "List(1, 2, 3, 4)")
 test (List (1, 0), 10, 100, "List(10)")
 test (List (41, 15, 156, 123, 254, 156, 141, 2, 24), 256, 16, "List(2, 9, 0, 15, 9, 12, 7, 11, 15, 14, 9, 12, 8, 13, 0, 2, 1, 8)")
 test (List (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
   2, 10, "List(1, 2, 3, 7, 9, 4, 0, 0, 3, 9, 2, 8, 5, 3, 8, 0, 2, 7, 4, 8, 9, 9, 1, 2, 4, 2, 2, 3)")
 test (List (41, 42, 43), 256, 36, "List(1, 21, 29, 22, 3)")

Passed all tests.

J, 109 105
Handles thousands of digits no sweat. No integers harmed!
e=:<.@%,.|~
t=:]`}.@.(0={.)@((e{:)~h=:+//.@)^:_
s=:[t[:+/;.0]*|.@>@(4 :'x((];~[t((*/e/)~>@{.)h)^:(<:#y))1')

Examples
256 16 s 41 15 156 123 254 156 141 2 24
2 9 0 15 9 12 7 11 15 14 9 12 8 13 0 2 1 8

256 36 s 41 42 43
1 21 29 22 3

16 16 s 1 2 3 4
1 2 3 4

256 46 s ?.1000$45
14 0 4 23 42 7 11 30 37 10 28 44 ...

time'256 46 s ?.3000$45'  NB. Timing conversion of 3000-vector.
1.96s

It gets shorter.

Smalltalk, 128
o:=[:n :b|n>b ifTrue:[(o value:n//b value:b),{n\\b}]ifFalse:[{n}]].
f:=[:a :f :t|o value:(a inject:0into:[:s :d|s*f+d])value:t].

tests:
f value:#[41 15 156 123 254 156 141 2 24]
  value:256
  value:16.
    -> #(2 9 0 15 9 12 7 11 15 14 9 12 8 13 0 2 1 8)

f value:#[1 2 3 4]
  value:16
  value:16.
    -> #(1 2 3 4)

f value:#[1 0]
  value:10
  value:100.
    -> #(10)

f value:#[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
  value:2
  value:10.
    -> #(1 2 3 7 9 4 0 0 3 9 2 8 5 3 8 0 2 7 4 8 9 9 1 2 4 2 2 3)

f value:#[41 42 43]
  value:256
  value:36.
    -> #(1 21 29 22 3)

and for your special amusement (challenge: figure out, what's so special about the input value):
f value:#[3 193 88 29 73 27 40 245 35 194 58 189 243 91 104 156 144 128 0 0 0 0]
  value:256
  value:1000.
    -> #(1 405 6 117 752 879 898 543 142 606 244 511 569 936 384 0 0 0)

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

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


text:
Visualize long division with ASCII art
Write a program that visualizes long division with ASCII art.  Input consists of two integers, a numerator and a denominator, using the input format of your choice.
Examples:
1234 ÷ 56:
     22
   ----
56|1234
   112
   ---
    114
    112
    ---
      2

1002012 ÷ 12:
     83501
   -------
12|1002012
    96
   ---
     42
     36
     --
      60
      60
      --
        12
        12
        --

0 ÷ 35
   0
   -
35|0

Rules:

Use of the programming language's division operator is allowed.
Use of big integer support is also allowed.
For consistency:

If the quotient is zero, print a single zero at the end of the diving board.
If the remainder is zero, do not print it.
Do not print leading zeros on any numbers.

Excess newlines at the end and trailing spaces to the right are allowed.
Solution with the fewest characters wins.

Limits:

0 <= numerator <= 1072 - 1
1 <= denominator <= 9999999

This implies that the output will never be wider than 80 columns.
Test suite and sample implementation:
You can use long-division.c (gist) to test your program.  It is actually a bash script with a C program inside.  Tweak it to invoke your program in the test suite.  Look at the C code at the bottom to see the reference implementation.  Please let me know if there are any problems with the sample program or test suite.
$ ./long-division.c 10 7
   1
  --
7|10
   7
  --
   3
$ ./long-division.c
PASS 1234 ÷ 56
PASS 1002012 ÷ 12
PASS 1 ÷ 1
--- snip ---

Score: 35 / 35
All tests passed!

Edit: By request, I put the test suite input and expected output into text files (gist).  Sample usage (bash):
cat input | while read nd; do
    ./program $nd |
        sed 's/\s*$//' | sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba'
done > output

diff -u expected output

The weird sed commands filter out trailing newlines and spaces from the program output.

I think the output is a bit biased towards the English-speaking golfing audience: http://en.wikipedia.org/wiki/Long_division#Notation_in_non-English-speaking_parts_of_the_world

Python 3, 284 257 characters
div.py
n,t=input().split()
d=int(t)
l=lambda x:len(str(x))
s=l(n)
def p(x):print(' '*(l(d)+s-l(x)+1)+str(x))
p(int(n)//d)
p('-'*s)
p(t+'|'+n)
s=z=f=0
while t:
 try:
  while z<d:z=z*10+int(n[s]);s+=1
 except:t=0
 if z*f:p(z)
 if t:f=1;t=z//d*d;p(t);p('-'*l(z));z-=t

Usage: python3 div.py
Input: from keyboard
test.py
import sys
sys.stdin=open('input'); sys.stdout=open('output','w')
for line in open('input'): exec(open('div.py').read())

output matches expected
Versions:
 1. 284
 2. 257: s,z,f=0,0,0→s=z=f=0; z and f→z*f; better looping; removed a few newlines.

you may try ideone for python3 and input - http://ideone.com/clone/ZZyzu

Haskell, 320 characters
l=length
(®)=replicate
p!v=p&show v
p&s=(p-l s)®' '++s
0§_=[];_§l=l
d[m,n]=l c!(read m`div`e):l c&(l m®'-'):c:drop 1(g 0(map(toInteger.fromEnum)m)$1+l n)where
 e=read n;c=n++'|':m
 g r(d:z)p=i§[o!k,o!(i*e),o&(l(show k)®'-')]++g j z o where k=r*10+d-48;(i,j)=k`divMod`e;o=1+p
 g r[]p=r§[p!r]
main=interact$unlines.d.words

Passes all tests. While is this pretty golf'd -- I think there is still yet more to be done here...

Edit: (344 -> 339) delay read calls, which reduces need to call show, enough that abbreviating show as s isn't worth it.
Edit: (339 -> 320) rewrote string field formatting functions

Neat!  I did a Haskell solution with 344 characters, but didn't post it.  Also, I didn't know you could use Unicode symbols for operators (without -XUnicodeSyntax).

JavaScript (400 394 418)
function d(n,d){t=parseInt;p=function(v){return(s+v).substring(v.length)};a=function(v,c){return v.replace(/\d/g,c)};w='\n';q=b=o=c=e='';s=a(d,' ')+' ';f=true;i=-1;z='0';while(++i<n.length){s+=' ';if(t(c+=n[i])>=t(d)){q+=r=Math.floor(t(c)/t(d));o+=(!f?p(c)+w:e)+p(''+r*t(d))+w+p(a(c,'-'))+w;c=t(c)%t(d);f=false}else if(!f){q+=z;}c=(c==0)?e:e+c}return p(!q?z:q)+w+p(a(n,'-'))+w+d+'|'+n+w+o+(q?p(c):e)}

NOTE: As tempting as it looks to shave off a few chars by replacing c=(c==0)? with c=!c?, it is not usable because it causes floating point-related bugs.
http://jsfiddle.net/nLzYW/9/
Sample Execution:
document.writeln("
");
document.writeln(d("1234","56"));
document.writeln();
document.writeln(d("1002012","12"));
document.writeln();
document.writeln(d("0","35"));
document.writeln();
document.writeln(d("123000123000123","123"));
document.writeln("
");

Edit 1: Minor bug fixes, numerous code optimizations.
Edit 2: Fix bug with 1/7 generating extra output.

314 bytes

AWK, 422 bytes
I think it took me over a week to solve this problem.
function l(x){return length(x)}{P=9(d=$2);gsub(".",FS,P);N=l(L=n=$1);gsub(".","-",L);O(0,q=int($1/$2));Q=l(q);print P L RS d"|"n}function O(i,x){printf"%"l(d)+N-Q+1+i"d\n",x}m=substr(q,1,1)*d{for(i=1;i<=Q;){O(i,m);print P substr(L,1,N-Q+1);for(_=l(j=n)-l(n-=m*10**(Q-i));_--;)P=P FS;if(!n)exit;match(q,".0*");i+=R=RLENGTH;sub(".{"R"}",E,q);b=q+0?substr(n,1,M=l(m=substr(q,1,1)*d)):n;if(b<m)b=substr(n,1,M+1);O(i-(i>Q),b)}}

Try it online!
Usage

Input is given from STDIN, as single line.
Two natural numbers are on same line.
Output is returned to STDOUT.
This program does never handle overflow; fails on huge values.
This program does not handle multiple lines of input correctly; only the first line is handled correctly.

Formatted
function l(x){
  return length(x)}
{
  P=9(d=$2);gsub(".",FS,P);
  N=l(L=n=$1);gsub(".","-",L);
  O(0,q=int($1/$2));
  Q=l(q);
  print P L RS d"|"n}
function O(i,x){
  printf"%"l(d)+N-Q+1+i"d\n",x}
m=substr(q,1,1)*d{
  for(i=1;i<=Q;){
    O(i,m);
    print P substr(L,1,N-Q+1);
    for(_=l(j=n)-l(n-=m*10**(Q-i));_--;)
      P=P FS;
    if(!n)
      exit;
    match(q,".0*");
    i+=R=RLENGTH;
    sub(".{"R"}",E,q);
    b=q+0?substr(n,1,M=l(m=substr(q,1,1)*d)):n;
    if(b<m)
      b=substr(n,1,M+1);
    O(i-(i>Q),b)}}

Javascript: (372)
function g(a){for(var c="",e=0;e<a;e++)c=" "+c;return c}function i(a,c){for(var e=a+"/"+c+"\\",j=(""+c).split(""),k="",d=0,b=0;b<j.length;b++){d*=10;d+=parseInt(j[b],10);var f=d>9?b-1:b,h=0;h=Math.floor(d/a);d%=a;f=g(f+a.toString().split("").length);f+=h*a+"\n"+g(b+a.toString().split("").length)+"--\n"+g(b+a.toString().split("").length)+d+"\n";k+=f;e+=h}return e+"\n"+k}

Invoke by using i(divider,number).
Codegolfed JS: http://jsfiddle.net/puckipedia/EP464/
Ungolfed (dutch) JS: http://jsfiddle.net/puckipedia/M82VM/
Returns the long division (in dutch format as i learned it):
5/25\05
 0
 --
 2
 25
  --
  0

Testcase:
document.write("
"+i(5,25)+"
");
document.write("
"+i(7,65669726752476)+"
");

Interesting. Though as @BlaXpirit says, it doesn't follow the spec. The spec is intended to be a fair standard of comparison for determining efficiency of code-golfed code, so you can't arbitrarily change the spec even if you don't agree with the output format :)

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


text:
Forking Factorials
This golf requires a factorial calculation be split up among multiple threads or processes.
Some languages make this easier to coordinate than others, so it is lang agnostic.
Ungolfed example code is provided, but you should develop your own algorithm.
The goal of the contest is to see who can come up with the shortest (in bytes, not seconds) multicore factorial algorithm for calculating N! as measured by votes when the contest closes.  There should be a multicore advantage, so we'll require that it should work for N ~ 10,000.  Voters should vote down if the author fails to provide a valid explanation of how it spreads out the work among processors/cores and vote up based on golf conciseness.
For curiosity, please post some performance numbers.  There may be a performance vs golf score tradeoff at some point, go with golf so long as it meets the requirements. I'd be curious to know when this occurs.
You may use normally available single core big integer libraries. For instance, perl is usually installed with bigint.  However, note that simply calling a system provided factorial function won't normally split the work across multiple cores.
You must accept from STDIN or ARGV the input N and output to STDOUT the value of N!. You may optionally use a 2nd input parameter to also provide the number of processors/cores to the program so it doesn't do what you'll see below :-)  Or you may design explicitly for 2, 4, whatever you have available.
I will post my own oddball perl example below, previously submitted on Stack Overflow under Factorial Algorithms in Different Languages. It is not golf.  Numerous other examples were submitted, many of them golf but many not.  Because of share-alike licensing, feel free to use the code in any examples in the link above as a starting point.
Performance in my example is lackluster for a number of reasons: it uses too many processes, too much string/bigint conversion.  As I said it is an intentionally oddball example. It will calculate 5000! in under 10 seconds on a 4 core machine here.  However, a more obvious two liner for/next loop can do 5000! on one of the four processors in 3.6s.
You'll definitely have to do better than this:
#!/usr/bin/perl -w
use strict;
use bigint;
die "usage: f.perl N (outputs N!)" unless ($ARGV[0] > 1);
print STDOUT &main::rangeProduct(1,$ARGV[0])."\n";
sub main::rangeProduct {
    my($l, $h) = @_;
    return $l    if ($l==$h);
    return $l*$h if ($l==($h-1));
    # arghhh - multiplying more than 2 numbers at a time is too much work
    # find the midpoint and split the work up :-)
    my $m = int(($h+$l)/2);
    my $pid = open(my $KID, "-|");
      if ($pid){ # parent
        my $X = &main::rangeProduct($l,$m);
        my $Y = <$KID>;
        chomp($Y);
        close($KID);
        die "kid failed" unless defined $Y;
        return $X*$Y;
      } else {
        # kid
        print STDOUT &main::rangeProduct($m+1,$h)."\n";
        exit(0);
    }
}

My interest in this is simply (1) alleviating boredom; and (2) learning something new.  This isn't a homework or research problem for me.
Good luck!

You can't count shortest code by votes, and the golfing and multi-threaded requirement seem to go poorly together.

My ancient single core notebook can do 10000! in less than 0.2 sec in Python.

Multi-threading a CPU-bound process will almost always slow it down.  All you are doing is adding overhead with little or no performance gain.  Multi-threading is for I/O-wait.

@mellamokb: I beg to differ for multi-core systems.

@Joey: Ah. Missed that small detail :s Agreed

@gnibbler -- Python with gmpy is surprisingly good at this. Perhaps I am behind the times... import gmpy - gmpy.fac(10000)

@Paul, I used reduce(operator.mul, range(1,10001)). The standard math module also has factorial() although not as fast as gmpy.fac()

Tht task shouldn't be so difficult using haskell. The RTS takes care about threads and parallelizing a calcuation is as easy as adding par and pseq at appropriate places.

Bash is also known to create multiple procesess in only a few bytes of script ...

Thanks for participating.  Currently I think the Mathematica is the shortest... next time require GPL-licensed interpreters/compilers... Oh, and thanks eBusiness for reminding me that votes != shortest... of course...

Mathematica
A parallel-capable function :
 f[n_, g_] := g[Product[N@i, {i, 1, n, 2}] Product[N@i, {i, 2, n, 2}]]

Where g is Identity or Parallelize depending on the type of process required
For the timing test, we'll slightly modify the function, so it returns the real clock time.
f[n_, g_] := First@AbsoluteTiming[g[Product[N@i,{i,1,n,2}] Product[N@i,{i,2,n,2}]]]

And we test both modes (from 10^5 up to 9*10^5):  (only two kernels here)
ListLinePlot[{Table[f[i, Identity],    {i, 100000, 900000, 100000}],
              Table[f[i, Parallelize], {i, 100000, 900000, 100000}]}]

Result:

Are you missing a ] in the first code line? It looks unbalanced.

@Peter Thanks, the last "]" didn't make its way through the copy buffer. Corrected.

This appears to be the shortest. It also looks like the fastest, unless I am misreading something.  I no longer subscribe to Mathematica so can't verify.  Thanks for participating.

Haskell: 209 200 198 177 chars
176 167 source + 33 10 compiler flag
This solution is pretty silly.  It applies product in parallel to a value of type [[Integer]], where the inner lists are at most two items long.  Once the outer list is down to at most 2 lists, we flatten it and take the product directly.  And yes, the type checker needs something annotated with Integer, otherwise it won't compile.
import Control.Parallel.Strategies
s(x:y:z)=[[x,y::Integer]]++s z;s x=[x]
p=product
f n=p$concat$(until((<3).length)$s.parMap rseq p)$s[1..n]
main=interact$show.f.read

(Feel free to read the middle part of f between concat and s as "until I heart the length")
Things seemed like they were going to be pretty good since parMap from Control.Parallel.Strategies makes it pretty easy to farm this out to multiple threads.  However, it looks like GHC 7 requires a whopping 33 chars in command line options and environment vars to actually enable the threaded runtime to use multiple cores (which I included in the total).  Unless I am missing something, which is possible definitely the case.  (Update: the threaded GHC runtime appears to use N-1 threads, where N is the number of cores, so no need to fiddle with run time options.)
To compile:
ghc -threaded prog.hs

Runtime, however, was pretty good considering the ridiculous number of parallel evaluations being sparked and that I didn't compile with -O2.  For 50000! on a dual-core MacBook, I get:
SPARKS: 50020 (29020 converted, 1925 pruned)

INIT  time    0.00s  (  0.00s elapsed)
MUT   time    0.20s  (  0.19s elapsed)
GC    time    0.12s  (  0.07s elapsed)
EXIT  time    0.00s  (  0.00s elapsed)
Total time    0.31s  (  0.27s elapsed)

Total times for a few different values, the first column is the golfed parallel, the second is the naive sequential version:
          Parallel   Sequential
 10000!      0.03s        0.04s
 50000!      0.27s        0.78s
100000!      0.74s        3.08s
500000!      7.04s       86.51s

For reference, the naive sequential version is this (which was compiled with -O2):
factorial :: Integer -> Integer
factorial n = product [1..n]
main = interact $ show.factorial.read

IMO, you don't have to count the args for the compiler and interpreter.

@FUZxxl: Normally I would agree, but this problem specifically requested that it run in multiple threads or processes, and those flags are required to make that happen (with GHC 7.0.2, from the latest Haskell Platform, at least).

Java, 523 519 434 430 429 chars
import java.math.*;public class G extends Thread{BigInteger o,i,r=BigInteger.ONE,h;G g;G(BigInteger O,int
I,int n){o=O;i=new BigInteger(""+I);if(n>1)g=new G(O.subtract(r),I,n-1);h=n==I?i:r;start();}public void
run(){while(o.signum()>0){r=r.multiply(o);o=o.subtract(i);}try{g.join();r=r.multiply(g.r);}catch(Exception
e){}if(h==i)System.out.println(r);}public static void main(String[] args){new G(new BigInteger(args[0]),4,4);}}

The two 4s in the final line are the number of threads to use.
50000! tested with the following framework (ungolfed version of the original version and with a handful fewer bad practices - although it's still got plenty) gives (on my 4-core Linux machine) times
7685ms
2338ms
1361ms
1093ms
7724ms

Note that I repeated the test with one thread for fairness because the jit might have warmed up.
import java.math.*;

public class ForkingFactorials extends Thread { // Bad practice!
    private BigInteger off, inc;
    private volatile BigInteger res;

    private ForkingFactorials(int off, int inc) {
        this.off = new BigInteger(Integer.toString(off));
        this.inc = new BigInteger(Integer.toString(inc));
    }

    public void run() {
        BigInteger p = new BigInteger("1");
        while (off.signum() > 0) {
            p = p.multiply(off);
            off = off.subtract(inc);
        }
        res = p;
    }

    public static void main(String[] args) throws Exception {
        int n = Integer.parseInt(args[0]);
        System.out.println(f(n, 1));
        System.out.println(f(n, 2));
        System.out.println(f(n, 3));
        System.out.println(f(n, 4));
        System.out.println(f(n, 1));
    }

    private static BigInteger f(int n, int numThreads) throws Exception {
        long now = System.currentTimeMillis();
        ForkingFactorials[] th = new ForkingFactorials[numThreads];
        for (int i = 0; i < n && i < numThreads; i++) {
            th[i] = new ForkingFactorials(n-i, numThreads);
            th[i].start();
        }
        BigInteger f = new BigInteger("1");
        for (int i = 0; i < n && i < numThreads; i++) {
            th[i].join();
            f = f.multiply(th[i].res);
        }
        long t = System.currentTimeMillis() - now;
        System.err.println("Took " + t + "ms");
        return f;
    }
}

Java with bigints is not the right language for golfing (look at what I have to do just to construct the wretched things, because the constructor which takes a long is private), but hey.
It should be completely obvious from the ungolfed code how it breaks up the work: each thread multiplies an equivalence class modulo the number of threads. The key point is that each thread does roughly the same amount of work.

Ruby - 111 + 56 = 167 characters
This is a two file script, the main file (fact.rb):
c,n=*$*.map(&:to_i)
p=(0...c).map{|k|IO.popen("ruby f2.rb #{k} #{c} #{n}")}
p p.map{|l|l.read.to_i}.inject(:*)

the extra file (f2.rb):
c,h,n=*$*.map(&:to_i)
p (c*n/h+1..(c+1)*n/h).inject(:*)

Simply takes the number of processes and number to calculate as args and splits the work up into ranges that each process can calculate individually.  Then multiplies the results at the end.
This really shows how much slower Rubinius is to YARV:
Rubinius:
time ruby fact.rb 5 5000 #=> 61.84s

Ruby1.9.2:
time ruby fact.rb 5 50000 #=> 3.09s

(Note the extra 0)

inject can take a symbol as argument, so you can save a character by using inject(:+). Here's the example from the docs: (5..10).reduce(:+).

@Michael: Thanks :).  Also just noticed that I had an 8 where there should have been a * if anyone had problems running this.

CSharp - 206 215 chars
using System;using System.Numerics;using System.Threading.Tasks;class a{static void Main(){var n=int.Parse(Console.ReadLine());var r=new BigInteger(1);Parallel.For(1,n+1,i=>{lock(this)r*=i;});Console.WriteLine(r);}}

Splits up the calculation with the C# Parallel.For() functionality.
Edit; Forgot lock
Execution times:
n = 10,000, time: 59ms.
n = 20,000, time: 50ms.
n = 30,000, time: 38ms.
n = 40,000, time: 100ms.
n = 50,000, time: 139ms.
n = 60,000, time: 164ms.
n = 70,000, time: 222ms.
n = 80,000, time: 266ms.
n = 90,000, time: 401ms.
n = 100,000, time: 424ms.
n = 110,000, time: 501ms.
n = 120,000, time: 583ms.
n = 130,000, time: 659ms.
n = 140,000, time: 832ms.
n = 150,000, time: 1143ms.
n = 160,000, time: 804ms.
n = 170,000, time: 653ms.
n = 180,000, time: 1031ms.
n = 190,000, time: 1034ms.
n = 200,000, time: 1765ms.
n = 210,000, time: 1059ms.
n = 220,000, time: 1214ms.
n = 230,000, time: 1362ms.
n = 240,000, time: 2737ms.
n = 250,000, time: 1761ms.
n = 260,000, time: 1823ms.
n = 270,000, time: 3357ms.
n = 280,000, time: 2110ms.

Scala (345 266 244 232 214 characters)
Using Actors:
object F extends App{import actors.Actor._;var(t,c,r)=(args(1).toInt,self,1:BigInt);val n=args(0).toInt min t;for(i<-0 to n-1)actor{c!(i*t/n+1 to(i+1)*t/n).product};for(i<-1 to n)receive{case m:Int=>r*=m};print(r)}

Edit - removed references to System.currentTimeMillis(), factored out a(1).toInt, changed from List.range to x to y
Edit 2 - changed the while loop to a for, changed the left fold to a list function that does the same thing, relying on implicit type conversions so the 6 char BigInt type appears only once, changed println to print
Edit 3 - found out how to do multiple declarations in Scala
Edit 4 - various optimizations I've learned since I first did this
Ungolfed version:
import actors.Actor._
object ForkingFactorials extends App
{
    var (target,caller,result)=(args(1).toInt,self,1:BigInt)
    val numthreads=args(0).toInt min target
    for(i<-0 to numthreads-1)
        actor
        {
            caller ! (i*target/numthreads+1 to(i+1)*target/numthreads+1).product
        }
    for(i<-1 to numthreads)
        receive
        {
            case m:Int=>result*=m
        }
    print(result)
}

Perl, 140
Takes N from standard input.
use bigint;$m=<>;open A,'>',
undef;$i=$p=fork&&1;$n=++$i;
{$i+=2;$n*=$i,redo if$i<=$m}
if($p){wait;seek A,0,0;$_=<A
>;print$n*$_}else{print A$n}

Features:

computation split: evens on one side and odds on the other (anything more complex than that would need a lot of characters to balance the computation load appropriately.
IPC using a shared anonymous file.

Benchmark:

10000! is printed in 2.3s forked, 3.4s unforked
100000! is printed in 5'08.8 forked, 7'07.9 unforked

Scala-2.9.0 170
object P extends App{
def d(n:Int,c:Int)=(for(i<-1 to c)yield(i to n by c)).par
println((BigInt(1)/: d(args(0).toInt,args(1).toInt).map(x=>(BigInt(1)/: x)(_*_)))(_*_))}

ungolfed:
object ParallelFactorials extends App
{
  def distribute (n: Int, cores: Int) = {
    val factorgroup = for (i <- 1 to cores)
      yield (i to n by cores)
    factorgroup.par
  }

  val parallellist = distribute (args(0).toInt, args(1).toInt)

  println ((BigInt (1) /: parallellist.map (x => (BigInt(1) /: x) (_ * _)))(_ * _))

}

The factorial of 10 is computed on 4 cores by generating 4 Lists:

1 5 9
2 6 10
3 7
4 8

which are multiplied in parallel. There would have been a simpler approach to distribute the numbers:
 (1 to n).sliding ((n/cores), (n/cores)

1 2 3
4 5 6
7 8 9
10

But the distribution wouldn't be that good - the smaller numbers would all end in the same list, the highest in another one, leading to the longer computation in the last list (for high Ns, the last thread wouldn't be almost empty, but at least contain (N/cores)-cores elements.
Scala in version 2.9 contains parallel Collections, which handle the parallel invocation themselves.

Erlang - 295 characters.
First thing I've ever written in Erlang so I wouldn't be surprised if someone could easily halve this:
-module(f).
-export([m/2,f/4]).
m(N,C)->g(N,C,C,[]).
r([],B)->B;
r(A,B)->receive{F,V}->r(lists:delete(F,A),V*B)end.
s(H,L)->spawn(f,f,[self(),H,L,1]).
g(N,1,H,A)->r([s(N div H,1)|A],1);
g(N,C,H,A)->g(N,C-1,H,[s(N*C div H,N*(C-1) div H)|A]).
f(P,H,H,A)->P!{self(),A};
f(P,H,L,A)->f(P,H-1,L,A*H).

Uses the same threading model as my earlier Ruby entry: splits the range up into sub-range and multiplies the ranges together in seperate threads then multiplies the results back in the main thread.
I wasn't able to figure out how to get escript working so just save as f.erl and open up erl and run:
c(f).
f:m(NUM_TO_CALC, NUM_OF_PROCESSES).

with appropriate substitutions.
Got around 8s for 50000 in 2 processes and 10s for 1 process, on my MacBook Air (dual-core).
Note: Just noticed it freezes if you attempt more processes than the number to factorialize.


text:
Find all number pairs that sum to 121212
This problem is quite easy to do by brute force.  In fact, it'll be reasonably fast to brute force as well.  But where's the fun in that?
The Problem
Produce a list of all unique 5 digit number pairs that sum to 121212.  However, each decimal digit must appear exactly once in either number.  So a valid pair would be (98167, 23045).  But an invalid pair would be (23456, 97756) because 7, 5, 6 are repeated more than once, and 1, 8, 0 are not used at all.  There are exactly 192 unique pairs.
Rules

Efficiency: You can brute force this.  But that's trivial to do.  So instead, the real challenge here is to find a way to efficiently produce the list of numbers.
Source Code Requirements: It cannot store the number list (or any part of it).  The number sequence must be generated on the fly.

Have Fun!

Did I miss the part where you said "Assume base 10"? ;)

@kojiro: How many fingers do YOU have? :-)

@kojiro: Nope.  If you can find other bases where it works, by all means...  I think that would be awesome!

@kojiro kind of: "each decimal digit must appear ..." although it seems you could find two 5-digit hex numbers as long as they don't contain A-F

@mellamokb 10 fingers, but I have 20 digits.

JavaScript
function findpairs(arrin1,arrin2){
    functioncount++
    var arr1=[]
    var arr2=[]
    var strike=[]
    var overflow=0
    var b
    var len=arrin1.length
    for(var a=0;a<len;a++){
        arr1[a]=arrin1[a]
        arr2[a]=arrin2[a]
        strike[arr1[a]]=true
        strike[arr2[a]]=true
        overflow=+((arr1[a]+arr2[a])>9)
    }
    var desired=12-(len%2)-overflow
    for(a=9;a>0;a--){
        b=(desired-a)%10
        if(a>b && !strike[a] && !strike[b]){
            if(len==4){
                if((a+b)>9){
                    document.write(""+a+arr1[3]+arr1[2]+arr1[1]+arr1[0]+" "+b+arr2[3]+arr2[2]+arr2[1]+arr2[0]+"
")
                    document.write(""+a+arr1[3]+arr1[2]+arr1[1]+arr2[0]+" "+b+arr2[3]+arr2[2]+arr2[1]+arr1[0]+"
")
                    document.write(""+a+arr1[3]+arr1[2]+arr2[1]+arr1[0]+" "+b+arr2[3]+arr2[2]+arr1[1]+arr2[0]+"
")
                    document.write(""+a+arr1[3]+arr1[2]+arr2[1]+arr2[0]+" "+b+arr2[3]+arr2[2]+arr1[1]+arr1[0]+"
")
                    document.write(""+a+arr1[3]+arr2[2]+arr1[1]+arr1[0]+" "+b+arr2[3]+arr1[2]+arr2[1]+arr2[0]+"
")
                    document.write(""+a+arr1[3]+arr2[2]+arr1[1]+arr2[0]+" "+b+arr2[3]+arr1[2]+arr2[1]+arr1[0]+"
")
                    document.write(""+a+arr1[3]+arr2[2]+arr2[1]+arr1[0]+" "+b+arr2[3]+arr1[2]+arr1[1]+arr2[0]+"
")
                    document.write(""+a+arr1[3]+arr2[2]+arr2[1]+arr2[0]+" "+b+arr2[3]+arr1[2]+arr1[1]+arr1[0]+"
")
                    document.write(""+a+arr2[3]+arr1[2]+arr1[1]+arr1[0]+" "+b+arr1[3]+arr2[2]+arr2[1]+arr2[0]+"
")
                    document.write(""+a+arr2[3]+arr1[2]+arr1[1]+arr2[0]+" "+b+arr1[3]+arr2[2]+arr2[1]+arr1[0]+"
")
                    document.write(""+a+arr2[3]+arr1[2]+arr2[1]+arr1[0]+" "+b+arr1[3]+arr2[2]+arr1[1]+arr2[0]+"
")
                    document.write(""+a+arr2[3]+arr1[2]+arr2[1]+arr2[0]+" "+b+arr1[3]+arr2[2]+arr1[1]+arr1[0]+"
")
                    document.write(""+a+arr2[3]+arr2[2]+arr1[1]+arr1[0]+" "+b+arr1[3]+arr1[2]+arr2[1]+arr2[0]+"
")
                    document.write(""+a+arr2[3]+arr2[2]+arr1[1]+arr2[0]+" "+b+arr1[3]+arr1[2]+arr2[1]+arr1[0]+"
")
                    document.write(""+a+arr2[3]+arr2[2]+arr2[1]+arr1[0]+" "+b+arr1[3]+arr1[2]+arr1[1]+arr2[0]+"
")
                    document.write(""+a+arr2[3]+arr2[2]+arr2[1]+arr2[0]+" "+b+arr1[3]+arr1[2]+arr1[1]+arr1[0]+"
")
                    resultcount+=16
                }
            }
            else{
                arr1[len]=a
                arr2[len]=b
                findpairs(arr1,arr2)
            }
        }
    }
}
resultcount=0
functioncount=0
start=+new Date()
findpairs([],[])
end=+new Date()
document.write("
"+resultcount+" results
"+(end-start)+" ms
"+functioncount+" function calls")

Hosted at: http://ebusiness.hopto.org/findpairs.htm
Mathematical realization: If you have one pair 15 others can trivially be generated by swapping digits between the two numbers, therefore I only search for numbers where the digits of the first are all greater than the digits of the second, and then simply output all the permutations.
I start from the least significant digits and generate the sequence as a tree traversal, for each step asserting that the intermediate result is correct and that no digits are spent twice. With these methods the function need only be called 50 times in total. On my machine Chrome yield runtime results of typically 2 ms.

C++
#include<iostream>
using namespace std;
#include<algorithm>

int main()
{
    long long N,F,S;
    char str[11]="1023456789";
    while (1) {
        sscanf(str,"%lld",&N);
        F=N/100000;S=N%100000;
        if (F>60000)
           break;
        if (F+S==121212)
           printf("%lld %lld\n",F,S);
        next_permutation(str,str+10);
    }
}

http://www.ideone.com/Lr84g

Very interesting.  So you're iterating over all possible permutations where the upper part is less than 60001 (about 1,768,168 iterations, or a little less than 10!/2) and then checking if it's summable to 121212.  Not bad at all for a first run.  But I'm still curious if we can get more efficient...

Hmm I thought you weren't allowed to store the number list... Ambiguous phrasing ?

@bltxd: I meant store it before hand.  You can store it as you generate it.  But you can't store that (51430, 69872) is a valid pair.  You can pre-store the digit list (0123456789) and the sum (121212).

I agree that it is not the most efficient way to do it, but I hope it is different.

Python 2.
It's pretty efficient because it constructs the numbers (the inner-most loop is executed 4570 times total) and pretty short because I golfed a little (201 characters), but I'm not really sure I want to explain this :)
p=lambda t,a,d:((x,y)for x in range(10)for y in[(t-x-a)%10]if(x not in d)&(y not in d)and x-y)
w=lambda s:[s]if len(s)==10and s[:5]<s[5:]else(m for n in p(2-len(s)/2%2,sum(s[-2:])/10,s)for m in w(s+n))

The returned values are pretty peculiar, though: call w with an empty tuple, and you get an iterator of 10-tuples. These 10 tuples are the digits of the two numbers, alas backwards and alternating, i.e. the tuple
(2, 0, 8, 3, 7, 4, 9, 1, 6, 5)

represents the numbers 51430 and 69782.
Test:
result = list(w(()))

assert len(set(result)) == 192               # found all values
assert len(result) == 192                    # and no dupes

for digits in result:
    assert all(0 <= d <= 9 for d in digits)  # real digits -- zero through nine
    assert len(set(digits)) == 10            # all digits distinct

    n1 = int("".join(map(str, digits[9::-2])))
    n2 = int("".join(map(str, digits[8::-2])))

    assert n1 + n2 == 121212                 # sum is correct

Here is the ungolfed version:
ppcalls = 0       # number of calls to possiblePairs
ppyields = 0      # number of pairs yielded by possiblePairs
ppconstructed = 0 # number of construced pairs; this is the number
                  #     of times we enter the innermost loop

def possiblePairs(theirSumMod10, addition, disallowed):
    global ppcalls, ppyields, ppconstructed
    ppcalls += 1
    for a in range(10):
        b = (theirSumMod10 - a - addition) % 10
        ppconstructed += 1
        if a not in disallowed and b not in disallowed and a != b:
            ppyields += 1
            yield (a, b)

def go(sofar):
    if len(sofar) == 10:
        if sofar[:5] < sofar[5:]: # dedupe
            yield sofar

    digitsum = 2 - (len(sofar) / 2) % 2 # 1 or 2, alternating

    for newpair in possiblePairs(digitsum, sum(sofar[-2:]) / 10, sofar):
        for more in go(sofar + newpair):
            yield more

list(go(()))        # iterate

print ppcalls       # 457
print ppyields      # 840
print ppconstructed # 4570

C
#include <stdio.h>

int mask(int n)
{
    int ret = 0;

    for (; n > 0; n /= 10)
        ret |= 1 << n % 10;

    return ret;
}

int main(void)
{
    int a, b;

    for (a = 21213, b = 99999; a < b; a++, b--)
        if ((mask(a) | mask(b)) == 0x3FF)
            printf("%d %d\n", a, b);

    return 0;
}

This traverses all pairs of 5-digit numbers that sum to 121212 (meaning 39393 iterations, or ~1/46th of the iterations used by fR0DDY's answer).  For each pair, it forms a bit mask of the digits in each number, then sees if they OR to 0b1111111111.

If you add the 10 iterations for mask every time, it leaves the time complexity only ~1/5 times better then mine. :)

Javascript (481)
function m(d,i){o=d-i;if(0<=o&&o<=9&&o!=i)return o;o+=10;if(0<=o&&o<=9&&o!=i)return o;return}function p(n,a){x=0;r=[];d=n%10;for(i=0;i<10;i++){if((!a||!a.contains(i))&&(o=m(d,i))&&(!a||!a.contains(o))&&i+o<=n)r[x++]=[i,o]}return r}function f(n,a){var x=0;var r=[];var d=p(n,a);for(var i=0;i<d.length;i++){var s=Math.floor((n-d[i][0]-d[i][1])/10);if(s>0){var t=f(s,d[i].concat(a));for(var j=0;j<t.length;j++)r[x++]=[t[j][0]*10+d[i][0],t[j][1]*10+d[i][1]]}else{r[x++]=d[i]}}return r}

http://jsfiddle.net/XAYr3/4/
Basic idea: generate combinations of valid digits that can be used in the right-most column.  For instance, (0,2), (3,9), (4,8), (5,7).  For each combination, recursively find pairs that work for the next-from-right digit, without duplicating digits in the first pair.  Recurse until a pair of 5-digit numbers has been generated.  Combine all those results into a single array, and the list is 192 elements.  This I believe should require about the fewest iterations, but all of the array allocation/deallocation makes it overall somewhat practically inefficient.
My counting tests show that function f is called 310 times, the inner loop i is executed 501 times total (across all calls to f), and the inner-inner loop j is executed 768 times total (across everything).

Python, 171 characters
def R(x,y,d,c):
 if not d and x<y:print x,y
 for p in d:
  q=(12-c%2-p-(x+y)/10**c)%10
  if p-q and q in d:R(x+p*10**c,y+q*10**c,d-set([p,q]),c+1)
R(0,0,set(range(10)),0)

The code maintains the invariant that x,y have c digits and that all the unused digits are in the set d.
The routine R is called a total of 841 times, which is pretty efficient.

C++
#include<iostream>
using namespace std;
#include<algorithm>
#include<cstring>

int main()
{
        int i;
        char str1[11]="0123456789",str2[11];
        for (i=99999;i>60000;i--)
        {
                sprintf(str2,"%d%d",i,121212-i);
                sort(str2,str2+10);
                if(!strcmp(str1,str2))
                        printf("%d %d\n",i,121212-i);
        }
}

http://www.ideone.com/Lr84g