How to find whether an array include a pair of which product equals to N in Python

1 Answer

0 votes
def ProductExists(lst, N):
    seen_values = set()

    for num in lst:
        if N % num == 0 and N // num in seen_values:
            return True
        seen_values.add(num)

    return False

lst = [5, 7, 13, 25, 9, 3, 4]
N = 21

print(ProductExists(lst, N))  



'''
run:

True

'''


 



answered Jul 21, 2023 by avibootz
...