while(1)
{
y = x;

for(i=0; i<n; i++) y = (1 + r)*y - 12*answer;

if(y <= 0) break;

answer++;
}
これとかどうよ?