Skip to content

Commit acf9668

Browse files
committed
102차 1번 문제풀이
1 parent 5c0fd80 commit acf9668

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const filePath =
5+
process.platform === "linux"
6+
? "/dev/stdin"
7+
: path.join(__dirname, "input.txt");
8+
9+
const input = fs.readFileSync(filePath, "utf8").toString().trim();
10+
11+
function solution(input) {
12+
const N = input;
13+
14+
const an = [];
15+
an[0] = 0;
16+
an[1] = 1;
17+
// an[2] = 3;
18+
// an[3] = 5;
19+
// an[4] = 11;
20+
// an[5] = 21;
21+
// an[6] = 43;
22+
for (let i = 2; i <= N; i++) {
23+
an[i] = (an[i - 1] * 2 + (i % 2 === 1 ? -1 : 1)) % 10007;
24+
// console.log(`A(${i}) = ${an[i]}`);
25+
}
26+
27+
return an[N];
28+
}
29+
30+
console.log(solution(input));

0 commit comments

Comments
 (0)