For anyone that’s bored, what’s the most concise code you can come up with to print out factorial(n) for n in the range 1-11 , in your language of choice?
- If there are any bored Perl programmers about I’m expecting Perl to win … here’s my best attempt in “C” … be interesting to see how different languages compare [?!]
#include <stdio.h>
long factorial(long n) { return n==1?n:n*factorial(n-1); }
int main() { for(int i=1;i<12;i++) printf("Factorial %d = %ld\n",i,factorial(i)); }