C programming challenge
C.NORTHRUP
cjn at homxb.ATT.COM
Fri Mar 10 08:22:57 AEST 1989
Kevin Meier and Jim Weythman (from AT&T Bell Labs) have submitted an entry for the
factorial program. It is 89 characters + 1 character for the new-line.
The guidelines being followed were as follows:
a number must be read from the keyboard
if number < 1 or number > 9
then
printf("error\n");
else
compute factorial of number
printf("answer is %d\n", answer)
end if
NOTE: you must use C programming language
error message must be printed with the format "error\n" (or given in upper case)
answer message must be printed with the format "answer is %d\n",
original post said that number of characters is code is counted via wc(1).
(therefore #include <stdio.h> would add 18 characters)
nothing in the original post about how long it takes to compute factorial.
(so time is not a question)
nothing in original post about using anything other then standard libraries
(so only libc.a would be acceptable)
original post used scanf("%d"...) to read in the digit(s). therefore valid
data could be entered as: 45the_following_letters_are_discarded
since all(?) scanf(3), in this case, would recognize the leading digits
4 and 5,
original post tested for the numeric bounds of ( 0 < number < 10 ). there
is no test for alphanumeric (other than scanf)
BEFORE FLAMES ARE TURNED UP PLEASE NOTE: this is only to clear up some
confusion. don't take it to heart, nor take it to seriously....
I have also received an entry from Kjell E. Post at the University of Calif
who completed it in 91 characters, as did Robert Bruce at Berkely.
charlie northrup
"I am not the official score keeper"
More information about the Comp.lang.c
mailing list