Here's a contest I think most people can give a try. The goal is to implement a program in C or C++ that compute precisely the factorial of N (N being an non-negative integer) as fast as possible.
For people who wouldn't know what's a factorial: http://en.wikipedia.org/wiki/Factorial
But I guess most of us have all seen somewhere as an introduction to recursion this kind of code
Of course, this code when compiled on a "normal" machine will yields incorrect result if N is larger than 12. So this doesn't interest us.Code:
unsigned int factorial(unsigned int N)
if (N == 0 || N == 1)
return N * factorial(N - 1);
The factorial to compute will be given as a command line argument.
The result has to be print to stdout. It can be either in decimal or in hexadecimal format.
The machine specifications are:
- Intel Core2 Duo (64-bit instruction set, SSE4.1 support, dual core, 6 MB of L2 cache)
- 4 GB of RAM
The target compiler is GCC 4.2.3 on a 64-bits Linux system (I'm using Ubuntu 8.04 64-bits). Since i'm quite new to Linux-based operating systems, don't make your code overly complicated to compile or you'll have to explain me how to get it works :). A shell script (sh or bash) or a makefile would be ideal...
And here's some rules.
- You can't use mathematics libraries, except if you are the author or if it's the standard C/C++ math library. In fact, if someone want to use an "advanced" mathematic library, he can but his program won't be taken into account when it will be time to declare the winner of the contest.
- You can't use pre-calculated factorial, except for 1! and 0!. This is simply not interesting.
Note that every submission you submit (you can submit more than one if you want, I don't care) will be publicly available after, so everyone will be able to take a look at what people's did.
I encourage people with less experience to participate. That's just going to be more fun. And it's not that hard to make a working implementation.
Also, please put all your source code in a folder and include a README text file which would contains your cboard alias and directives on how to compile your solution. If you use libraries not easily found or not easily installable on a typical Linux distribution, gives indications where to get them. Also, specify in which base is the output. And zip the folder.
The contest ends in 3 weeks, which means June 15th, 22:00 GMT.
(And sorry for all the English mistakes i may have made)