Chapter 10: Working with Workers samples
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
const n = 10;
|
||||
// Fibonacci calculator
|
||||
const fibonacci = (n) => {
|
||||
let a = 0, b = 1, next = 1, i = 2;
|
||||
for (i; i <= n; i++) {
|
||||
next = a + b;
|
||||
a = b;
|
||||
b = next;
|
||||
}
|
||||
console.log(`The Fibonacci number at position ${n} is ${next}`);
|
||||
};
|
||||
|
||||
fibonacci(n);
|
||||
console.log("...");
|
||||
Reference in New Issue
Block a user