Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 24th, 2006, 4:00 PM   #1
uman
Expert Programmer
 
Join Date: Dec 2004
Posts: 794
Rep Power: 4 uman is on a distinguished road
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
uman is offline   Reply With Quote
Old Aug 24th, 2006, 4:06 PM   #2
AntiNinja
Hobbyist Programmer
 
AntiNinja's Avatar
 
Join Date: Jun 2006
Location: The States
Posts: 101
Rep Power: 3 AntiNinja is on a distinguished road
Send a message via AIM to AntiNinja Send a message via Yahoo to AntiNinja
So are we not saying the language, or wtf fibonacci is, or making the entry's compileable?
__________________
Pain is just weakness leaving the body.
AntiNinja is offline   Reply With Quote
Old Aug 24th, 2006, 4:06 PM   #3
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Old Aug 24th, 2006, 4:11 PM   #4
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3 Jimbo is on a distinguished road
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?
Jimbo is offline   Reply With Quote
Old Aug 24th, 2006, 4:13 PM   #5
AntiNinja
Hobbyist Programmer
 
AntiNinja's Avatar
 
Join Date: Jun 2006
Location: The States
Posts: 101
Rep Power: 3 AntiNinja is on a distinguished road
Send a message via AIM to AntiNinja Send a message via Yahoo to AntiNinja
Well we could always do 500 ways A-Z?
__________________
Pain is just weakness leaving the body.
AntiNinja is offline   Reply With Quote
Old Aug 24th, 2006, 4:15 PM   #6
glimmy
Programmer
 
glimmy's Avatar
 
Join Date: May 2005
Location: Minnesota
Posts: 42
Rep Power: 0 glimmy is on a distinguished road
Send a message via AIM to glimmy
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)))
glimmy is offline   Reply With Quote
Old Aug 24th, 2006, 4:16 PM   #7
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 579
Rep Power: 5 Benoit is on a distinguished road
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
Benoit is offline   Reply With Quote
Old Aug 24th, 2006, 4:17 PM   #8
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 770
Rep Power: 3 Jimbo is on a distinguished road
it's taken as a parameter, and just print the single value, I guess
Jimbo is offline   Reply With Quote
Old Aug 24th, 2006, 4:22 PM   #9
Random Spirit
Unverified User
 
Join Date: Aug 2006
Posts: 88
Rep Power: 0 Random Spirit is on a distinguished road
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.
Random Spirit is offline   Reply With Quote
Old Aug 24th, 2006, 4:22 PM   #10
glimmy
Programmer
 
glimmy's Avatar
 
Join Date: May 2005
Location: Minnesota
Posts: 42
Rep Power: 0 glimmy is on a distinguished road
Send a message via AIM to glimmy
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
glimmy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 7:38 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC