Skip to content

Instantly share code, notes, and snippets.

@mpadmore
Created February 28, 2018 21:01
Show Gist options
  • Save mpadmore/c60ceb2def7002bb27f8f0990e3b851c to your computer and use it in GitHub Desktop.
Save mpadmore/c60ceb2def7002bb27f8f0990e3b851c to your computer and use it in GitHub Desktop.
Fibonacci example function
<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