27 lines
698 B
Python
27 lines
698 B
Python
def calc_gen4(a, r):
|
|
current = a
|
|
while True:
|
|
yield current
|
|
current *= r
|
|
|
|
|
|
while True:
|
|
print("геометрическая прогрессия")
|
|
print("1 - Запустить")
|
|
print("0 - Выход")
|
|
choice = input("Выбор: ")
|
|
|
|
if choice == "0":
|
|
break
|
|
|
|
if choice == "1":
|
|
try:
|
|
a = float(input("Первый член: "))
|
|
r = float(input("Знаменатель: "))
|
|
n = int(input("Сколько элементов вывести: "))
|
|
gen = calc_gen4(a, r)
|
|
for _ in range(n):
|
|
print(next(gen))
|
|
except:
|
|
print("Ошибка ввода")
|