tests/gcc/common/src/ackermann.c

/* -*- mode: c -*-
 * $Id: ackermann.c,v 1.2 2003/12/30 01:21:23 davidw Exp $
 * http://www.bagley.org/~doug/shootout/
 */

/* Changes: sleep removed (antirez) */

/* END COMMENT  */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int Ack(int M, int N) { return(M ? (Ack(M-1,N ? Ack(M,(N-1)) : 1)) : N+1); }

int main(int argc, char *argv[]) {
    int n = ((argc == 2) ? atoi(argv[1]) : 1);

    printf("Ack(3,%d): %d\n", n, Ack(3, n));
    /* sleep long enough so we can measure memory usage */
    return(0);
}


Generated by GNU enscript 1.6.3.