Created
February 28, 2018 21:01
-
-
Save mpadmore/c60ceb2def7002bb27f8f0990e3b851c to your computer and use it in GitHub Desktop.
Fibonacci example function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
function fibonacci(nth) { | |
fibString = "1"; | |
if (nth GT 1) { | |
prev2 = 0; | |
prev1 = 1; | |
for (i=2; i LTE nth; i=i+1) { | |
thisItem = prev2 + prev1; | |
fibString = fibstring & " " & thisItem; | |
prev2 = prev1; | |
prev1 = thisItem; | |
} | |
} | |
return fibString; | |
} | |
writeOutput(fibonacci(12)); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment