-
-
Notifications
You must be signed in to change notification settings - Fork 770
Added Korean translation #214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
782fe23
Add Korean translation
KANGPUNGYUN 0bd308e
Update 진약수의 합.md
KANGPUNGYUN 3f55041
Merge branch 'TheAlgorithms:master' into master
KANGPUNGYUN be3569e
Added Korean translation
KANGPUNGYUN 9fcbce9
Add missing value in magic square
KANGPUNGYUN 4cc5444
Update 마방진.md
KANGPUNGYUN 34ad478
Update 유클리드 알고리즘.md
KANGPUNGYUN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# 마방진이란? | ||
|
||
마방진이란 모든 행, 열, 주대각선과 일반적으로 다른 대각선의 일부 혹은 모든 대각선 방향으로 수를 모두 더하면 그 합이 같도록 배열된 고유한 정수를 포함하는 정사각형으로 정의한다. | ||
|
||
# 마방진 공식 | ||
|
||
`n`차 마방진은 일반적으로 `n²`개의 고유한 정수 숫자들을 정사각형 안에 정리한 것이다. 모든 행, 열, 대각선의 `n` 개의 숫자를 합하면 같은 상수가 된다. 마방진은 1부터 `n²`까지의 정수를 가진다. 모든 행, 열 및 대각선의 고정 합을 마법 상수 또는 마법합이라고 한다. 이를 M이라는 문자로 표시한다. 전형적인 마방진의 마법 상수는 전적으로 `n`의 값에 따라 결정된다. 따라서 마법합의 값은 다음 공식을 사용하여 계산한다: | ||
|
||
- M = `n(n² + 1)/2` | ||
|
||
- 이는 다른 차수의 마방진을 만드는 데 사용되는 마방진 공식이다. (`n²` + 1)에서 각 위치의 숫자를 빼면, 또 다른 마방진을 만들 수 있는데, 이를 서로 보완적인 마방진(complementary magic square)이라고 부른다. 그리고 1부터 시작하여 연속된 자연수들로 이루어진 마방진을 정규(normal) 마방진이라고 알려져 있다. | ||
|
||
# 마방진을 푸는 방법 | ||
|
||
위에서 언급한 바와 같이, 마법합의 공식은 n(n² + 1)/2이다.\ | ||
3차 마방진에 경우, n = 3 을 대입하여 마법합의 값을 구한다면 3×3 마방진을 쉽게 형성할 수 있다. | ||
|
||
`n = 3`일 경우, 마법합 = 3(3\*3 + 1)/2 = 3(9 + 1)/2 = (3 × 10)/2 = 15이다.\ | ||
이제, 우리는 각 행, 열, 대각선 방향으로 더한 숫자들의 합이 15와 동일하도록 각각의 위치에 숫자를 배치해야 한다. | ||
|
||
## 3차 마방진 만들기 요령 | ||
|
||
`x`를 마방진의 차수라고 하자. | ||
|
||
이 경우, `x = 3`이다. | ||
|
||
`x`와 `y`의 곱이 마법합의 값인 15가 되는 또 다른 숫자 `y`를 생각해 보자. | ||
|
||
그렇다면, `y = 5 {xy = (3)(5) = 15}` | ||
|
||
y의 값은 항상 정사각형 정중앙에 있어야 하고, x의 값은 y의 값 왼쪽 셀에 있어야 한다.\ | ||
x 위의 셀은 아래의 이미지처럼 y – 1를 가진다: | ||
|
||
 | ||
 | ||
 | ||
|
||
위 마방진의 서로 보완적인 마방진(complementary magic square)을 만들자. | ||
|
||
`(n² + 1) = 32 + 1 = 9 + 1 = 10` | ||
|
||
이제, (n² + 1)의 값인 10에서 각 숫자를 빼라. | ||
|
||
- 첫 번째 행의 숫자들: | ||
|
||
- 10 – 4 = 6 | ||
- 10 – 3 = 7 | ||
- 10 – 8 = 2 | ||
|
||
- 두 번째 행의 숫자들: | ||
|
||
- 10 – 9 = 1 , | ||
- 10 – 5 = 5 , | ||
- 10 – 1 = 9 | ||
|
||
- 세 번째 행의 숫자들: | ||
- 10 – 2 = 8 , | ||
- 10 – 7 = 3 , | ||
- 10 – 6 = 4 | ||
|
||
 | ||
|
||
# 참조 | ||
|
||
## 웹사이트 | ||
|
||
- [Byjus](https://byjus.com/maths/magic-square/) | ||
- [geeksforgeeks](https://www.geeksforgeeks.org/magic-square/) | ||
|
||
## The Algorithms 페이지 | ||
|
||
- [마방진](https://the-algorithms.com/ko/algorithm/magic-square) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# 유클리드 알고리즘 | ||
|
||
## 문제 | ||
|
||
양의 정수 $a$와 $b$의 최대공약수 $g = gcd(a, b)$를 구하시오. 여기서 $g$는 나머지 없이 $a$와 $b$ 모두 나누는 가장 큰 수로 정의한다. | ||
|
||
## 발상 | ||
|
||
유클리드 알고리즘은 큰 수에서 작은 수를 빼면 두 수의 최대공약수가 변하지 않는다는 단순한 관찰을 기반한다: | ||
|
||
$a > b$인 상황에서 $g$는 $a$와 $b$의 최대공약수라고 하자. | ||
그렇다면 $g$는 $a$와 $b$를 나눌 수 있다. 따라서 $g$는 $a - b$도 나눌 수 있다. (분배법칙) | ||
|
||
$g'$를 $b$와 $a - b$의 최대공약수라 하자. | ||
|
||
$g' = g$ 귀류법: | ||
|
||
$g' < g$ 또는 $g' > g$이라고 가정하자. | ||
|
||
$g' < g$일 때, $g'$는 _최대_ 공약수가 될 수 없다. | ||
$g$도 $a - b$와 $b$의 공약수이기 때문이다. | ||
|
||
$g' > g$일 때, $g'$는 $b$와 $a - b$의 약수이다 - | ||
즉, $g'n = b$와 $g'm = a - b$로 표현할 수 있는 정수 $n, m$이 존재한다. | ||
따라서 $g'm = a - g'n \iff g'm + g'n = a \iff g'(m + n) = a$이다. | ||
이는 $g'$도 $a$의 약수이며, $g$가 $a$와 $b$의 최대공약수라는 초기 가정과 $g' > g$는 모순이다. | ||
|
||
## 구현 | ||
|
||
실제 실행에서 속도를 높이기 위해 반복해서 뺄셈하는 대신 나머지 연산이 사용된다: | ||
$b$는 $a >= b$만큼 $a$에서 여러 번 반복해서 뺄 수 있다. | ||
이러한 뺄셈 후에는 $b$로 나눌 때 $a$의 나머지만 남게 된다. | ||
|
||
간단한 Lua 구현은 다음과 같다: | ||
|
||
```lua | ||
function gcd(a, b) | ||
while b ~= 0 do | ||
a, b = b, a % b | ||
end | ||
return a | ||
end | ||
``` | ||
|
||
`%`가 나머지 연산자임을 유의하자; | ||
각 단계에서 새로운 `a`에 `b`를 할당하고, | ||
새로운 `b`에는 `a`를 `b`로 나눈 나머지 연산한 값을 할당한다. | ||
|
||
## 분석 | ||
|
||
### 공간 복잡도 | ||
|
||
공간 복잡도는 약간 일정하다: | ||
(일정한 크기로 가정된) $a$와 $b$라는 두 개의 숫자만 저장한다. | ||
|
||
### 시간 복잡도 | ||
|
||
while문의 각 반복은 일정한 시간에 실행되며 최소한 $b$를 절반으로 줄인다. 따라서 $O(log_2(n))$는 런타임의 상한값이다. | ||
|
||
## 연습 | ||
|
||
$a = 42$와 $b = 12$의 최대공약수를 구하라: | ||
|
||
1. $42 \mod 12 = 6$ | ||
2. $12 \mod 6 = 0$ | ||
|
||
결과는 $gcd(42, 12) = 6$. | ||
|
||
유클리드 알고리즘을 사용하여 $a = 633$와 $b = 142$의 최대공약수를 구하라: | ||
|
||
1. $633 \mod 142 = 65$ | ||
2. $142 \mod 65 = 12$ | ||
3. $65 \mod 12 = 5$ | ||
4. $12 \mod 5 = 2$ | ||
5. $5 \mod 2 = 1$ | ||
6. $2 \mod 1 = 0$ | ||
|
||
결과는 $gcd(633, 142) = 1$: $a$와 $b$는 서로소이다. | ||
|
||
## 활용 | ||
|
||
- 분수 단축하기 | ||
- 최소공배수 구하기 | ||
- 두 수가 서로소인지 효율적으로 확인하기 (예: RSA 암호화 시스템에 필요) | ||
|
||
## 참고자료 | ||
|
||
- [위키피디아 "유클리드 호제법" 항목](https://ko.wikipedia.org/wiki/%EC%9C%A0%ED%81%B4%EB%A6%AC%EB%93%9C_%ED%98%B8%EC%A0%9C%EB%B2%95) | ||
Panquesito7 marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.