function movie(card, ticket, perc) {
percCount = rate => {
let rateCount = 0;
for (let i = 1; i <= rate; i++) {
rateCount += Math.pow(perc, i);
}
return rateCount;
}
for (let i = 1; ; i++) {
let systemA = ticket * i,
systemB = Math.ceil(card + (ticket * percCount(i)));
if (systemB < systemA) {
return i;
break;
}
}
};
function movie(card, ticket, perc) {
let count = 0;
let price = ticket;
let sum = card;
while (Math.ceil(sum) >= ticket * count) {
count++;
price *= perc;
sum += price;
}
return count;
}