programming challenge (silly)

Morris Barbara L c415-23 at alberta.UUCP
Sat Mar 4 18:09:46 AEST 1989


A friend and I tried to mimic the behaviour of the following program in
the fewest characters possible.  The best we were able to do was 98
characters (result of wc). Can anyone beat this?  Email for our solution.

main()
{
	int n;

	scanf( "%d", &n );
	if ( n < 1 || n >= 10 )
		printf( "error\n" );
	else printf( "answer is %d\n", factorial( n ) );
}

int factorial( n )
int n;
{	
	if ( n == 1 )
		return( n );
	else return( n * factorial( n - 1 ) );
}



More information about the Comp.lang.c mailing list