Talk:Ackermann function: Difference between revisions

From Rosetta Code
Content added Content deleted
(BC (arbitrary precision Bin Calculator): can be added?)
 
No edit summary
Line 19: Line 19:


Would this be suitable for adding in the article? --[[User:ShinTakezou|ShinTakezou]] 14:05, 9 December 2008 (UTC)
Would this be suitable for adding in the article? --[[User:ShinTakezou|ShinTakezou]] 14:05, 9 December 2008 (UTC)

: Why not ? [[User:Rahul|Rahul]] 14:45, 9 December 2008 (UTC)

Revision as of 14:45, 9 December 2008

Arbitrary precision with BC

BC is a binary calculator with arbitrary precision (similar to dc, but this one use the RPN, bc resembles C in its syntax); the code would be (translated from C):

#! /usr/bin/bc -q
define ack(m, n) {
   if ( m == 0 ) return (n+1);
   if ( n == 0 ) return (ack(m-1, 1));
   return (ack(m-1, ack(m, n-1)));
}

for(n=0; n<7; n++)
{
  for(m=0; m<4; m++)
  {
     print "A(", m, ",", n, ") = ", ack(m,n), "\n"; 
  }
}
quit

Would this be suitable for adding in the article? --ShinTakezou 14:05, 9 December 2008 (UTC)

Why not ? Rahul 14:45, 9 December 2008 (UTC)