Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/test/simulation/fixtures/edit/issue-7282/math.js
13405 views
1
2
export function fib(nth) {
3
if (nth <= 0) return 0;
4
if (nth === 1) return 0;
5
if (nth === 2) return 1;
6
7
return fib(nth - 1) + fib(nth - 2);
8
}
9
10
export function isOdd(n) {
11
return n % 2 !== 0;
12
}
13
14
export function sum(a, b) {
15
assert.strictEqual(typeof a, 'number', 'a must be of type number');
16
return a + b;
17
}
18
19
export function sub(a, b) {
20
return a - b;
21
}
22
23
export function sumArray(arr) {
24
return arr.reduce((sum, num) => sum + num, 0);
25
}
26
27
export function div(A, b) {
28
return A / b;
29
}
30
31
export function mul(a, b) {
32
return a * b;
33
}
34
35
36
export function isPrime(number) {
37
if (number <= 1) return false;
38
for (let i = 2; i <= Math.sqrt(number); i++) {
39
if (number % i === 0) {
40
return false;
41
}
42
}
43
return true;
44
}
45
46
47
export function isEven(n) {
48
return n % 2 === 0;
49
}
50
51