TelamonJoin Date: 2007-01-30 Post Count: 3614 |
This one might be a bit hard; I'm wondering if anyone can solve it. First correct solution wins 987 tix. Bonus tix for style.
----
function fib(n)
...
end
----
Fill in ... so that the fib function returns the nth Fibonacci number.
The Fibonacci Sequence starts: 0, 1, 1, 2, 3, 5, 8, ...
Each number in the sequence is the sum of the 2 numbers that come before it. For example, the 6th number in the sequence is 5. This is becuase 2 + 3 = 5.
|
|
TelamonJoin Date: 2007-01-30 Post Count: 3614 |
I'll give you guys a hint if no one gets it by the afternoon, so check back if you get stuck. |
|
Psychox77Join Date: 2007-07-21 Post Count: 188 |
Uhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh. 95?? lol |
|
CPRULEZTop 100 PosterJoin Date: 2007-05-29 Post Count: 3093 |
im not good at scripting but 0, 1, 1, 2, 3, 5, 8, i can go on forever with that and you also got that from cyberchase. LOL. ohh and do you mind if i post like 0, 1, 1, 2, 3, 5, 8, 13, and more? |
|
AnaminusTop 100 PosterJoin Date: 2006-11-29 Post Count: 5945 |
function fib(n)
fibs={1,1}
for i=3,n do
fibs[i]=fibs[i-1]+fibs[i-2]
end
return fibs[n]
end
That's one way, at least...
?-Anaminus-? |
|
CPRULEZTop 100 PosterJoin Date: 2007-05-29 Post Count: 3093 |
ur smart........ 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 1088 and so on. |
|
PCwienerJoin Date: 2007-03-03 Post Count: 3746 |
function fib(n)
fibs={3, 5}
for i=3, n do
fibs[i]=fibs[i-1]+fibs[i-2]
end
return fibs[n]
end
? |
|
jimmy347Join Date: 2007-02-25 Post Count: 700 |
function fib(n)
fibs={2,4 }
for i=3, n do
fibs[i]=fibs[i-1]+fibs[i-2]
end
return fibs[n]
end
{Jimmy} :-0 |
|
buttlad3Join Date: 2007-07-16 Post Count: 17 |
um splee |
|
jimmy347Join Date: 2007-02-25 Post Count: 700 |
function fib(n)
fibs={8,13 }
for i=3, n do
fibs[i]=fibs[i-1]+fibs[i-2]
end
return fibs[n]
end |
|
TelamonJoin Date: 2007-01-30 Post Count: 3614 |
Anaminus - nice solution. It's even better than the one I came up with since it uses less memory and is faster to execute. 200 tix bonus!
This is what I came up with:
function fib(n)
if (n <= 2) then return n - 1 end
if (n > 2) then return fib(n-1) + fib(n-2) end
end
|
|
MrDoomBringerTop 100 PosterJoin Date: 2006-11-21 Post Count: 6176 |
Well, that was fast. |
|
RoboticaJoin Date: 2007-05-23 Post Count: 4975 |
:O no kidding |
|
|
haloguyJoin Date: 2007-05-23 Post Count: 2286 |
brain hurts....>_< |
|
Mario68Top 100 PosterJoin Date: 2007-06-27 Post Count: 1063 |
i say. i am not good at scripting lol
but nice job. I got the ANAMINUS WINS. Whew, jimmy copied Anaminus |
|
|
gah this is confusing! i shuld stick with building ofr now on >.< |
|
slosoTop 100 PosterJoin Date: 2007-05-08 Post Count: 634 |
LOL Even looking at scripting destroyes my brain, now theres a script brainbuster >=( |
|
rusty2Join Date: 2007-03-10 Post Count: 1141 |
All i know how to do is Regenerateing scripts and admin doors!
+Rust+ |
|
TehYumzJoin Date: 2007-08-03 Post Count: 1896 |
id have to say
function fib(n)
fibs={3, 5}
for i=3, n do
fibs[i]=fibs[i-1]+fibs[i-2]
end
return fibs[n]
end
could be wrong though : \ |
|
NEGOKSAJoin Date: 2008-01-21 Post Count: 15 |
cool but how do i make admin shirt doors |
|
|
gergy008Join Date: 2008-03-16 Post Count: 7039 |
[ Content Deleted ] |
|
|
|
Darn! i had the same as anaminus
function fib(n)
fibs={1,1}
for i=3,n do
fibs[i]=fibs[i-1]+fibs[i-2]
end
return fibs[n]
end |
|