Fibonaci Counter
Author |
Message |
coldmine16
|
Posted: 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
|
|
|
[Gandalf]
|
Posted: 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. |
|
|
|
|
|
|
|