![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
Join Date: Dec 2004
Posts: 794
Rep Power: 4
![]() |
500 Ways to Print the Fibonacci Sequence
#1
unsigned fib(unsigned index)
{
if(index == 0 || index == 1)
return 1;
return fib(index-1) + fib(index-2);
}
__________________
Few people deserve to be compared to (Rush) Limbaugh, most of them were convicted at the Nuremburg trials. --WilliamSChips on Slashdot |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
So are we not saying the language, or wtf fibonacci is, or making the entry's compileable?
__________________
Pain is just weakness leaving the body.
|
|
|
|
|
|
#3 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
How about just 10 ways to print a fib?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#4 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3
![]() |
yeah, the Fibonacci sequence is a lot more limiting than just printing 1-10... besides the other thread took almost a year and a half, how long do you think this one would take?
|
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
Well we could always do 500 ways A-Z?
__________________
Pain is just weakness leaving the body.
|
|
|
|
|
|
#6 |
|
Programmer
|
2) Common Lisp
(defun fibonacci-recursive (n)
(if (<= n 1)
1
(+ (fibonacci-recursive (- n 1)) (fibonacci-recursive (- n 2)))))3) Common Lisp (defun fibonacci-iterative (n)
(do ((g n (- g 1))
(j 1 (+ j i))
(i 1 j))
((<= g 1) j))) |
|
|
|
|
|
#7 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 579
Rep Power: 5
![]() |
A-Z would be no different from 1-10 except you would add 64 and print an ASCII character. I think fibonacci is good, but to which term do we print?
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#8 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3
![]() |
it's taken as a parameter, and just print the single value, I guess
|
|
|
|
|
|
#9 |
|
Unverified User
Join Date: Aug 2006
Posts: 88
Rep Power: 0
![]() |
I think this is rather pointless. There are two ways to print the fibonacci sequence, recursion or a loop. You would just be implementing it in different programming languages. So unless we can find 250 languages to write it in then its going to be hard.
|
|
|
|
|
|
#10 |
|
Programmer
|
4) TI-Basic
Prompt X 1->Y 1->Z For(T,1,(X-1)) Y->P Z->Q P+Q->Y P->Z End Disp Y P.S. I'm out of ideas, other than changing languages |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| test | lostcauz | Coder's Corner Lounge | 9 | Jul 18th, 2006 4:20 PM |
| [Python] BlackJack | UnKnown X | Show Off Your Open Source Projects | 9 | Feb 20th, 2006 7:01 AM |
| First Python Programme: Fibonacci Finder | UnKnown X | Python | 2 | Dec 15th, 2005 7:19 PM |
| 2 new programs | HaCkeR | C | 30 | Nov 29th, 2005 8:14 AM |
| ftplib help please! | disAbled | Python | 1 | Jun 30th, 2005 9:05 PM |