xbonacci

Solutions on MaxInterview for xbonacci by the best coders in the world

showing results for - "xbonacci"
Andrea
10 Feb 2016
1const Xbonacci = (signature,n) => {
2    let orgArr = [...signature]
3    let len = orgArr.length
4    let sigLen = signature.length
5    let arr = []
6    if(n === 0){
7        return []
8    }else if(len > n){
9      orgArr = signature.slice(0, n)
10    }else{
11        for(let i = len; i < n; i++){
12            if(i <= n){
13                arr = orgArr.slice(-sigLen)
14                let nextValue = arr.reduce((acc, curr) => acc + curr, 0)
15                orgArr.push(nextValue)
16                arr = []
17            }else{
18                return 1
19            }
20        }
21    }
22    return orgArr
23}
similar questions
queries leading to this page
xbonacci