Path: utzoo!attcan!uunet!ncrlnk!ncrcae!hubcap!gatech!rutgers!tut.cis.ohio-state.edu!ucbvax!agate!saturn!kjell From: kjell@saturn.ucsc.edu (Kjell Post) Newsgroups: comp.lang.c Subject: Re: programming puzzle (silly) Message-ID: <6644@saturn.ucsc.edu> Date: 10 Mar 89 13:38:39 GMT References: <28336@ucbvax.BERKELEY.EDU> Reply-To: kjell@saturn.ucsc.edu (Kjell Post) Organization: University of California, Santa Cruz Lines: 27 In article <28336@ucbvax.BERKELEY.EDU> klier@ucbarpa.Berkeley.EDU (Pete Klier) writes: > >*********************** >main(m,n){scanf("%d",&n);for(m=n>0^n>9;n&&m*=n--;); >printf(m?"Answer=%d\n":"error\n",m);} >*********************** > But you changed the output. I also get an error compiling this on an ISI68K. As someone pointed out, my earlier solution breaks when arguments are supplied at the command line. I therefore propose the following as the shortest version: main(n,m){for(n=scanf("%d\n",&m);m>1&m<10;n*=m--); printf(m-1?"error\n":"answer is %d\n",n);} When written on a single line it should count to 91 characters. I would also like to add the rule that the program should compile without warnings from cc and lint (except for "scanf returns value which is always ignored" which is always ignored). -- For athletes and programmers, ! Kjell E. Post a woman is the end of their career. ! CIS/CE ! University of California, Santa Cruz -- A.Wickberg ! Email: kjell@saturn.ucsc.edu