Xref: utzoo sci.math:16831 comp.lang.c:38384 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!uunet!cme!libes From: libes@cme.nist.gov (Don Libes) Newsgroups: sci.math,comp.lang.c Subject: Re: fibonacci Numbers Keywords: Fibonacci Numbers - routines? Message-ID: <1690@muffin.cme.nist.gov> Date: 18 Apr 91 03:05:15 GMT References: <1991Apr12.051844.15063@milton.u.washington.edu> <1991Apr12.233715.665@craycos.com> Followup-To: sci.math Organization: National Institute of Standards and Technology Lines: 17 >> Can someone send me source code for a routine to calculate >>Fibonacci numbers to _x_ (x being input from user)? Additionally it'd >>be great if this found the PRIME numbers in the set. It could print its >Well, this program only prints the final answer, and doesn't find the >primes, but you should be able to modify it to do those things. >I O(c,v)I c;Yv;{W(v&&((c<2)?(U("?\n"),E(1)):1))?(U("%d\n",O(A(*++v)+1,(Y)0) >-2),0):((c>3)?O(c-1,(Y)0)+O(c-2,(Y)0)-2:3);} Nice, but why not go all the way and use the Best-Of-Show winner in last year's obfuscated C contest. Given the proper argument it would reverse itself thereby becoming a sort program. Upon sorting the original program (which did differential equations as well) it would produce Fibonacci numbers. Don Libes libes@cme.nist.gov ...!uunet!cme-durer!libes