Skip to content

Commit 5f8360c

Browse files
committed
Update
1 parent b181c2e commit 5f8360c

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
* 주어진 문서(단어별로 나뉘어진 배열)에서 특정 단어의 빈도를 구한다. [code](https://github.com/JaeYeopHan/algorithm_basic_java/blob/master/src/test/java/algorithm/basic/FrequencyStringInDocument.java)
1515

1616
### Basic Math
17-
* 주어진 두 수의 최대 공약수와 최소 공배수를 구한다. [code](https://github.com/JaeYeopHan/algorithm_basic_java/blob/master/src/test/java/algorithm/basic/GcdAndGcm.java)
17+
* 주어진 두 수의 최대 공약수와 최소 공배수를 구한다. [code](https://github.com/JaeYeopHan/algorithm_basic_java/blob/master/src/test/java/algorithm/basicMath/GcdAndGcm.java)
1818
* n개의 서로 다른 원소 중 r개의 원소를 순서없이 선택하는 방법의 수를 구한다. [code](https://github.com/JaeYeopHan/algorithm_basic_java/blob/master/src/test/java/algorithm/basicMath/BasicCombination.java)
1919
* 주어진 수보다 작은 소수의 개수를 구한다. [code](https://github.com/JaeYeopHan/algorithm_basic_java/blob/master/src/test/java/algorithm/basicMath/FindPrimeNumTest.java)
2020
* Fibonacci 를 계산하는 함수를 작성한다. [code](https://github.com/JaeYeopHan/algorithm_basic_java/blob/master/src/test/java/algorithm/basicMath/Fibonacci.java)
2121
* 주어진 정수의 각 자리 수의 합을 구한다. [code]
22-
* 사다리를 한 칸 또는 두 칸씩 오를 수 있다고 했을 때 사다리 높이에 따른 사다리 오르기 방법의 경우의 수를 구한다. [code]
22+
* 사다리를 한 칸 또는 두 칸씩 오를 수 있다고 했을 때 사다리 높이에 따른 사다리 오르기 방법의 경우의 수를 구한다. [code](https://github.com/JaeYeopHan/algorithm_basic_java/blob/master/src/test/java/algorithm/basicMath/Ladder.java)
2323

2424
### Recursion part
2525
* 주사위로 이동 가능한 경우의 수를 모두 구한다. [code](https://github.com/JaeYeopHan/algorithm_basic_java/blob/master/src/test/java/algorithm/recursion/Dice.java)

src/test/java/algorithm/basicMath/Ladder.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@ private int getCountOfCase(int one, int two, int num) {
4141
return result;
4242
}
4343

44-
// test code를 작성하다보니 이것이 피보나치 규칙을 따른다는 것을 알게 되었다.
45-
// Recursion version
46-
private int getCountOfCaseRec(int num) {
47-
if (num < 2) {
48-
return 1;
49-
}
50-
return getCountOfCaseRec(num - 1) + getCountOfCaseRec(num - 2);
51-
}
52-
5344
public int getByRecursion(int n, int r) {
5445
int cache[][] = new int[n + 1][r + 1];
5546
if (r == 0 || n == r) {
@@ -58,4 +49,13 @@ public int getByRecursion(int n, int r) {
5849
if (cache[n][r] != 0) return cache[n][r];
5950
return cache[n][r] = getByRecursion(n - 1, r - 1) + getByRecursion(n - 1, r);
6051
}
52+
53+
// test code를 작성하다보니 이것이 피보나치 규칙을 따른다는 것을 알게 되었다.
54+
// Recursion version
55+
private int getCountOfCaseRec(int num) {
56+
if (num < 2) {
57+
return 1;
58+
}
59+
return getCountOfCaseRec(num - 1) + getCountOfCaseRec(num - 2);
60+
}
6161
}

src/test/java/algorithm/basic/SumEachNum.java renamed to src/test/java/algorithm/basicMath/SumEachNum.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package algorithm.basic;
1+
package algorithm.basicMath;
22

33
import org.junit.Test;
44

0 commit comments

Comments
 (0)