
1_У исполнителя Калькулятор две команды, которым присвоены номера: 1. прибавь 2 2. умножь на 2
Сколько есть программ, которые число 2 преобразуют в число 40? ... 2_У исполнителя Калькулятор две команды, которым присвоены номера: 1. прибавь 3 2. умножь на 2 Сколько есть программ, которые число 3 преобразуют в число 42? ... 3_У исполнителя Калькулятор две команды, которым присвоены номера: 1. прибавь 1 2. прибавь 3 Сколько есть программ, которые число 1 преобразуют в число 15? ... 4_ У исполнителя Калькулятор две команды, которым присвоены номера: 1. прибавь 1 2. прибавь 3 Сколько есть программ, которые число 7 преобразуют в число 20? ... 5_У исполнителя Калькулятор три команды, которым присвоены номера: 1. прибавь 1 2. умножь на 2 3. умножь на 3 Сколько есть программ, которые число 1 преобразуют в число 14?

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

Ответ:
1. 195
2. 26
3. 129
4. 88
5. 48
Python:
def f1(start, x):
if start == x: return 1
if start > x: return 0
return f1(start + 1, x) + f1(start * 2, x)
print('1.', f1(2, 40))
def f2(start, x):
if start == x: return 1
if start > x: return 0
return f2(start + 3, x) + f2(start * 2, x)
print('2.', f2(3, 42))
def f3(start, x):
if start == x: return 1
if start > x: return 0
return f3(start + 1, x) + f3(start + 3, x)
print('3.', f3(1, 15))
def f4(start, x):
if start == x: return 1
if start > x: return 0
return f4(start + 1, x) + f4(start + 3, x)
print('4.', f4(7, 20))
def f5(start, x):
if start == x: return 1
if start > x: return 0
return f5(start + 1, x) + f5(start * 2, x) + f5(start * 3, x)
print('5.', f5(1, 14))



1. У исполнителя Калькулятор две команды, которым присвоены номера: 1. прибавь 2 2. умножь на 2. Сколько есть программ, которые число 2 преобразуют в число 40?
To find the number of programs that can transform the number 2 into the number 40 using the given commands, we can analyze the possible combinations of commands and their effects on the starting number.
Let's consider the two commands: 1. прибавь 2: This command adds 2 to the current number. 2. умножь на 2: This command multiplies the current number by 2.
To transform the number 2 into 40, we need to find a combination of these commands that achieves this transformation.
Let's analyze the possible combinations of commands and their effects on the starting number:
- If we start with the number 2 and apply the command "прибавь 2" once, the resulting number will be 4. - If we start with the number 2 and apply the command "умножь на 2" once, the resulting number will be 4. - If we start with the number 2 and apply the command "прибавь 2" twice, the resulting number will be 6. - If we start with the number 2 and apply the command "умножь на 2" twice, the resulting number will be 8. - If we start with the number 2 and apply the command "прибавь 2" three times, the resulting number will be 8. - If we start with the number 2 and apply the command "умножь на 2" three times, the resulting number will be 16. - If we start with the number 2 and apply the command "прибавь 2" four times, the resulting number will be 10. - If we start with the number 2 and apply the command "умножь на 2" four times, the resulting number will be 16. - If we start with the number 2 and apply the command "прибавь 2" five times, the resulting number will be 12. - If we start with the number 2 and apply the command "умножь на 2" five times, the resulting number will be 32. - If we start with the number 2 and apply the command "прибавь 2" six times, the resulting number will be 14. - If we start with the number 2 and apply the command "умножь на 2" six times, the resulting number will be 64.
Based on the analysis above, there are no combinations of commands that can transform the number 2 into the number 40.


Похожие вопросы
Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili