We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
💬 문제
[코딩테스트 연습 - 자릿수 더하기](https://school.programmers.co.kr/learn/courses/30/lessons/12931)
💬 Idea
n이 0이 될 때까지 while문을 돌며 answer에 n을 10으로 나눈 나머지를 더하고, n은 10으로 나눈 몫으로 바꿔준다.
💬 풀이
func solution(_ n:Int) -> Int { var answer:Int = 0 var n = n while n != 0 { answer += n % 10 n /= 10 } return answer }
💬 더 나은 방법?
func solution(_ n:Int) -> Int { return String(n).reduce(0, { $0 + Int(String($1))! }) }
The text was updated successfully, but these errors were encountered:
#63 - 자릿수 더하기 문제 풀이
2fb5958
hwangJi-dev
No branches or pull requests
💬 문제
[코딩테스트 연습 - 자릿수 더하기](https://school.programmers.co.kr/learn/courses/30/lessons/12931)
💬 Idea
n이 0이 될 때까지 while문을 돌며 answer에 n을 10으로 나눈 나머지를 더하고, n은 10으로 나눈 몫으로 바꿔준다.
💬 풀이
💬 더 나은 방법?
The text was updated successfully, but these errors were encountered: