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