def find_solutions(divisor, quotient, remainder, min_range, max_range):
solutions = []
for x in range(min_range, max_range + 1):
if x // divisor == quotient and x % divisor == remainder:
solutions.append(x)
return solutions
def find_min_solution(divisor, quotient, remainder, min_range, max_range):
solutions = find_solutions(divisor, quotient, remainder, min_range, max_range)
return min(solutions) if solutions else None
def find_max_solution(divisor, quotient, remainder, min_range, max_range):
solutions = find_solutions(divisor, quotient, remainder, min_range, max_range)
return max(solutions) if solutions else None
def find_analytical_solution(divisor, quotient, remainder):
x = divisor * quotient + remainder
if x // divisor == quotient and x % divisor == remainder:
next_x = x + divisor
is_unique = (next_x // divisor != quotient)
return x, is_unique
else:
return None, False
def main():
divisor = 17
quotient = 2
remainder = 1
min_range = 1
max_range = 100
print(f"Ищем решения для уравнений:"
print(f"x // {divisor} = {quotient}"
print(f"x % {divisor} = {remainder}"
print(f"где x - натуральное число от {min_range} до {max_range}"
solutions = find_solutions(divisor, quotient, remainder, min_range, max_range)
if solutions:
print(f"\nНайдены решения: {solutions}"
print(f"Всего решений: {len(solutions)}"
print(f"Минимальное решение: {min(solutions)}"
print(f"Максимальное решение: {max(solutions)}"
else:
print("\nРешений не найдено"
analytic_x, is_unique = find_analytical_solution(divisor, quotient, remainder)
if analytic_x:
print(f"\nАналитическое решение: x = {analytic_x}"
if is_unique:
print("Это решение единственное"
else:
print("Существуют и другие решения, отличающиеся на величину делителя"
if __name__ == "__main__":
main()