fibonacci Numbers

Don Libes libes at cme.nist.gov
Thu Apr 18 13:05:15 AEST 1991


>>     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 at cme.nist.gov      ...!uunet!cme-durer!libes



More information about the Comp.lang.c mailing list