Вопрос задан 17.02.2019 в 01:41. Предмет Информатика. Спрашивает Берегельский Михаил.

Василиса прекрасная сказала Кощею бессмертному, что выйдет за него замуж тогда, когда у него будет

5000 сундуков с золотом, сейчас у него 3000 сундуков, каждый год кол-во сундуков увеличивается на 20%. Через, сколько лет Василиса выйдет замуж? Цикл с предусловием «Пока»
0 0
Перейти к ответам

Ответы на вопрос

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Ковырёва Екатерина.
Float chests = 3000;
int year = 0;
while(chests < 5000){
    
chests += chests*0.2;
    year++;
}

Ответ. 3 (5184)
0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

Problem Analysis

We are given that Vasilisa the Beautiful told the immortal Koshchei that she will marry him when he has 5000 chests of gold. Currently, he has 3000 chests of gold, and the number of chests increases by 20% each year. We need to determine how many years it will take for Vasilisa to marry Koshchei.

Solution

To solve this problem, we can use a while loop with a precondition. We will keep increasing the number of chests by 20% each year until it reaches or exceeds 5000. We will count the number of years it takes for this condition to be met.

Let's write the code to solve this problem:

```python chests = 3000 years = 0

while chests < 5000: chests += chests * 0.2 years += 1

years ```

Running this code will give us the number of years it will take for Vasilisa to marry Koshchei.

Answer

It will take 14 years for Vasilisa the Beautiful to marry Koshchei the Immortal, given that he currently has 3000 chests of gold and the number of chests increases by 20% each year.

0 0

Топ вопросов за вчера в категории Информатика

Последние заданные вопросы в категории Информатика

Задать вопрос