728x90
๋ฐ์ํ
Problem
Solution
2๋ถํฐ n-1๊น์ง ๋๋๋ฉด์ ๋๋จธ์ง๊ฐ 1์ด ๋์ค๋ฉด ๋ฐํํ๋ค.
func solution(_ n:Int) -> Int {
for i in 2..<n {
if n%i == 1 {
return i
}
}
return 0
}
Source Code
728x90
๋ฐ์ํ
'๐ Problem Solution > Programmers' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Swift] ํ๋ก๊ทธ๋๋จธ์ค ์๊ฐ ์ฝ๋ ์ฑ๋ฆฐ์ง1 ์คํ ์์ด (0) | 2021.11.06 |
---|---|
[Swift] ํ๋ก๊ทธ๋๋จธ์ค ํ๋ ธ์ด์ ํ (0) | 2021.10.31 |
[Swift] ํ๋ก๊ทธ๋๋จธ์ค ์๊ฐ ์ฝ๋ ์ฑ๋ฆฐ์ง2 110 ์ฎ๊ธฐ๊ธฐ (0) | 2021.10.27 |
[Swift] ํ๋ก๊ทธ๋๋จธ์ค ์คํฐ์ปค ๋ชจ์ผ๊ธฐ(2) (0) | 2021.10.19 |
[Swift] ํ๋ก๊ทธ๋๋จธ์ค ์๊ฐ ์ฝ๋ ์ฑ๋ฆฐ์ง 3 ๊ธ๊ณผ ์ ์ด๋ฐํ๊ธฐ (0) | 2021.10.10 |
๋๊ธ