'Is there a function through which when a and b multiplies the resultant x is same,and x is given by the user

For example all combinations when multiplied together results in x=20. In first sequence, A = 2, B = 10.
2 x 10 = 20

5 x 4 = 20 etc

The sequences are required must be present in the list.



Solution 1:[1]

This is a general problem of number theory and there are several algorithms of varying complexity which can be used to perform an “integer factorisation”. The fastest would be the general number field sieve. There are several good examples for quadratic sieves that you can compare as well (e.g. SIMPQS). If you aren’t considering using it in a productive manner I recommend to look into Dixon's factorization method, since it’s a bit more comprehensible.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cr0ss