XP is just a number | |
PerlMonks |
Re: Fibonacci numbers (again)by ambrus (Abbot) |
on Sep 09, 2005 at 12:01 UTC ( [id://490532]=note: print w/replies, xml ) | Need Help?? |
This is even shorter, but it prints newlines, not spaces. It's better than the perl one because it calculates all digits. If it's enough to have the first say 40 elements of the sequence (depending on an internal limitation of dc) then this is 2 chars shorter:
If you insist on spaces, here's a version:
These depend on the dc extension command r (and the last one on n and P too), but these are present in both GNU dc and FreeBSD dc, so it might be portable now. Update 2006 nov 15: This is slightly longer than the above but is still interesting:
Update 2007 jul 17: some explanation in Re^3: Fibo Golf challenge on 3 monkeys.
In Section
Obfuscated Code
|
|