Skip to content

Instantly share code, notes, and snippets.

@mpelzsherman
Created September 18, 2019 19:09
Show Gist options
  • Save mpelzsherman/21cd5e78dbf90907587fec53816e10de to your computer and use it in GitHub Desktop.
Save mpelzsherman/21cd5e78dbf90907587fec53816e10de to your computer and use it in GitHub Desktop.
'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