Integer pairs of a product in Python This bit of code is looking for the pair of integers that make up a product.
You can input any integer and it returns the pairs of numbers that, when multiplied together, make it up.
I have done a pretty bad job at explaining this, but the code it pretty simple.
All comments welcome.
num = 498
num_1 = 1

while num_1 &lt; num:
    product = num / num_1
    if product &lt; num_1:
        break
    if product - int(product) == 0:
        print(f&quot;{num_1}, {int(product)}&quot;)
    num_1 += 1
Such while-loops that don't offer an advantage are unpythonic. And harder to understand. In your solution, the information about what the loop goes through is spread over six (!) lines. And I actually I need to read all 8 (!) lines, since I need to read the if/print as well in order to see that they don't affect the loop. Better use a for-loop, where it's all cleanly in one line.

If you do use such a while-loop, then there should be an empty line above your num_1 = 1, not under it. Because it belongs to the solution, not to the input.

Floating-point in general has precision issues, better avoid it if you can. Here it's simple to use just integers.

For num = 1, you don't print anything. You should print 1, 1.

Unless you have an actual reason for that formatting, keep it simple and don't format. If you use the output of your program as input for something else, it might also very well be easier to parse without that extra comma.


Resulting code:
from math import isqrt

num = 498

for i in range(1, isqrt(num) + 1):
    if num % i == 0:
        print(i, num // i)