Files
2022-05-06 00:49:26 +03:00

89 lines
1.5 KiB
Python
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import operator
import functools
prime = [2, 3]
def simple(a):
num = a[-1]+1
tr = False
while tr != True:
for i in range(2, num):
if num%i == 0:
tr = False
num += 1
break
else:
tr = True
a.append(num)
# print(f'В список добавлено число {num}')
def NOK(x,y):
if x > y:
difx = True
else:
difx=False
arrayx=[]
arrayy=[]
counter=0
while x!=1:
for i in range(counter, len(prime)):
if prime[i]>(x/2):
arrayx.append(x)
x=1
break
if x%prime[i]==0:
x //= prime[i]
arrayx.append(prime[i])
counter=0
i=0
break
if (x>1) and (i==(len(prime)-1)):
simple(prime)
counter=i
counter=0
while y!=1:
for i in range(counter, len(prime)):
if prime[i]>(y/2):
arrayy.append(y)
y=1
break
if y%prime[i]==0:
y//=prime[i]
arrayy.append(prime[i])
counter=0
i=0
break
if (y>1) and (i==(len(prime)-1)):
simple(prime)
counter=i
print(arrayx, arrayy)
count_ax = 0
y_second = list(arrayy)
x_second = list(arrayx)
for i in range(0, len(arrayy)):
for for_x in range(0, len(x_second)):
if arrayy[i] == x_second[for_x]:
y_second.remove(arrayy[i])
x_second.remove(arrayy[i])
break
result_array = y_second + arrayx
result = functools.reduce(operator.mul, result_array, 1)
print(result_array, result)
return result
first = int(input())
second = int(input())
print(NOK(first,second))
input()