Created
September 18, 2019 19:09
-
-
Save mpelzsherman/21cd5e78dbf90907587fec53816e10de to your computer and use it in GitHub Desktop.
This file contains 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
'use strict'; | |
function fib(maxLength=10, series=[1,1]) { | |
const l = series.length; | |
if (l >= maxLength) { | |
return series; | |
} | |
series.push(series[l-2] + series[l-1]); | |
return fib(maxLength, series); | |
} | |
module.exports.handler = async function(context, req) { | |
const series = fib(req.query.length || (req.body && req.body.length)) | |
context.res = { | |
body: series.join(','), | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment