public int solution(int a, int b, int n) { int answer = 0; while (n >= a) { int temp = n / a; answer += temp * b; n = temp * b + (n % a); } return answer; }
출처:https://school.programmers.co.kr/learn/courses/30/lessons/132267