import math
def solve_quadratic(a, b, c):
	if a == 0:
		if b == 0:
			print("No solution" if c != 0 else "Infinite solutions")
		else:
			print(f"The root of the given linear function is {-c / b}")
		return
	D = b**2 - 4*a*c
	if D < 0:
		print("No real roots")
	elif D == 0:
		print(f"One real root: {-b / (2*a)}")
	else:
		x1 = (-b - math.sqrt(D)) / (2*a)
		x2 = (-b + math.sqrt(D)) / (2*a)
		print(f"Roots: {x1} and {x2}")
def find_factorial(n):
	F = 1
	for i in range(1, n+1):
		F *= i
	print(f"Result is: {F}")
	return F

def fibonacci_sequence(n):
	a, b = 1, 2
	print("Fibonacci Sequence:")
	for _ in range(n):
		print(a, end=" ")
		a, b = b, a + b
	print() 


def collatz(n):
	print("Collatz sequence")
	while n > 1:
		print(n, end=" ")
		if n % 2 == 0:
			n = n // 2
		else:
			n = n * 3 + 1
	print(1)

answer = input("Do you want to solve a quadratic function? (Yes/No)").strip().lower()
if answer == "yes":
	a = float(input("Enter a: "))
	b = float(input("Enter b: "))
	c = float(input("Enter c: "))
	solve_quadratic(a, b, c)
else:
	answer = input("Do you want to find a factorial number? (Yes/No) ").strip().lower()
	if answer == "yes":
		m = int(input("Write a number: "))
		find_factorial(m)
	else:
		answer = input("Do you want to generate the first N Fibonacci numbers? (Yes/No)").strip().lower()
		if answer == "yes":
			n = int(input("Write a number: "))
			fibonacci_sequence(n)
		else:
			answer = input("Do you want to generate Collatz Conjecture? (Yes/No)").strip().lower()
			if answer == "yes":
				h = int(input("Write a number: "))
				collatz(h)
			else:
				print("Abort")
