function workbook(n, k, arr) {
let special = 0;
let page = 1;
for (let i = 0; i < n; i ++) {
const problems = arr[i];
let temp = 1;
const up = Math.ceil(problems / k);
while (temp <= up) {
const start = temp === 1 ? 1 : (k * (temp -1)) + 1;
console.log(start, up);
const end = temp === up ? problems : temp * k;
if ( page >= start && page <= end) {
special++;
}
page ++;
temp++;
}
}
return special
}
workbook(10, 5, [3, 8, 15, 11, 14, 1, 9, 2, 24, 31])
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)