Title Description
In vivo production line, each worker with increasing familiarity and experience with the mobile phone processing flow of knowledge, daily output will continue to rise.
Assuming that the first day of production units 1, the next two days (i.e. a second, three days) 2 production per day, the next 3 days (i.e. the fourth, fifth, six days) per day production 3 .... ..
so, program a mobile phone number to calculate the n-th day of a total volume production.
My problem solution
public int solution (int n) {
int res =0;//总产量
int day=0;//天数
for(int i=1;day<n;i++){
for(int j=1;j<=i&&day<n;j++){
day++;
res+=i;
}
}
return res;
}