-
Notifications
You must be signed in to change notification settings - Fork 0
/
complexity.js
62 lines (62 loc) · 1.88 KB
/
complexity.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
function complexFunction(input) {
let result = 0;
for (let i = 0; i < input.length; i++) {
if (input[i] % 2 === 0) {
result += input[i];
} else {
result -= input[i];
}
if (input[i] % 3 === 0) {
result *= 2;
} else if (input[i] % 5 === 0) {
result /= 2;
} else if (input[i] % 7 === 0) {
result += 10;
} else if (input[i] % 11 === 0) {
result -= 10;
} else if (input[i] % 13 === 0) {
result *= 3;
} else if (input[i] % 17 === 0) {
result /= 3;
} else if (input[i] % 19 === 0) {
result += 20;
} else if (input[i] % 23 === 0) {
result -= 20;
} else if (input[i] % 29 === 0) {
result *= 4;
} else if (input[i] % 31 === 0) {
result /= 4;
} else if (input[i] % 37 === 0) {
result += 30;
} else if (input[i] % 41 === 0) {
result -= 30;
} else if (input[i] % 43 === 0) {
result *= 5;
} else if (input[i] % 47 === 0) {
result /= 5;
} else if (input[i] % 53 === 0) {
result += 40;
} else if (input[i] % 59 === 0) {
result -= 40;
} else if (input[i] % 61 === 0) {
result *= 6;
} else if (input[i] % 67 === 0) {
result /= 6;
} else if (input[i] % 71 === 0) {
result += 50;
} else if (input[i] % 73 === 0) {
result -= 50;
} else if (input[i] % 79 === 0) {
result *= 7;
} else if (input[i] % 83 === 0) {
result /= 7;
} else if (input[i] % 89 === 0) {
result += 60;
} else if (input[i] % 97 === 0) {
result -= 60;
} else {
result += input[i] * 2;
}
}
return result;
}