Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Fibonaci Counter
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
coldmine16




PostPosted: Fri Aug 11, 2006 10:09 am   Post subject: Fibonaci Counter

here is a simple code i came up with to count the fibonaci code just change the for loop on how long you want it to go

code:

var num1, num2: int

num1 := 0
num2 := 1

put num2
for x : 1 .. 10
    num1 := num1 + num2
    num2 := num1 + num2
    put num1
    put num2
end for

Sponsor
Sponsor
Sponsor
sponsor
[Gandalf]




PostPosted: Fri Aug 11, 2006 3:50 pm   Post subject: (No subject)

There's a post a few below yours that has a fibonacci function as well. You could simply have posted it there.

Aside from that, I'll tell you why your code is worse, in some ways, than the two in the other topic. For one, both alternatives are functions which makes them a lot more usable in a practical situation. Using recursion, you have less code, and I believe it expresses what you are really doing in finding a fibonacci number much better than your code. Catalyst's function, on the other hand, runs thousands of times faster than the others, and is a quite interesting use of Phi. Smile
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: