Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions 3-extra/1-factorial.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@

function factorial(input) {
// TODO
let result=1
if (input===0 || input===1){
return 1
}else if (input > 1){
for (let i=input ;i > 1; i--){
result*=i
}
}
return result
}

/* ======= TESTS - DO NOT MODIFY ===== */
Expand Down
17 changes: 17 additions & 0 deletions 3-extra/3-fibonacci.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,25 @@

function generateFibonacciSequence(n) {
// TODO
let sum=0
let fibonacciArray=[0]

if(n===1){
return fibonacciArray
} else if (n>=2){
fibonacciArray.push(1)
for (i=2 ; i < n ; i++){
sum=fibonacciArray[fibonacciArray.length-1] +fibonacciArray[fibonacciArray.length-2]
fibonacciArray.push(sum)
}
return fibonacciArray
}else {
return `you should insert a positive integer number`
}
}

console.log(generateFibonacciSequence(4))

/* ======= TESTS - DO NOT MODIFY ===== */
test("should return the first 10 numbers in the Fibonacci Sequence", () => {
expect(generateFibonacciSequence(10)).toEqual(
Expand Down