thornik

Bench 'Ackerman' for D

Dec 5th, 2017
572
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ldc2.exe -release -m64 -O ackermann.d
  2.  
  3. import std.stdio;
  4. import std.conv;
  5.  
  6. int Ack(int M, int N)
  7. {
  8.     if (M == 0) return N + 1;
  9.     if (N == 0) return Ack(M - 1, 1);
  10.     return Ack(M - 1, Ack(M, (N - 1)));
  11. }
  12.  
  13. void main(string[] args)
  14. {
  15.    int n = args.length < 2 ? 1 : to!int(args[1]);
  16.    writefln(`Ack(3, %s): %s`, n, Ack(3, n));
  17. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×