How to List Integer Only / Returns Integer?

Because of the divisions, the integers are converted to floats.
You can check if a number is an integer by isinteger.

So if you replace your loop like this it should work

for i = 1:10
    p1 = p + i
    q1 = (q*p1)/p
    for j = 1:10
        p2 = p1 + i
        q2 = (q1*p2)/p1   
        if all(isinteger.((p1,q1,p2,q2)))
            println("$i \t ($p,$q) \t \t ($p1,$q1) \t \t ($p2,$q2)")
        end
    end
end
Output
2 	 (2,5) 	 	 (4,10.0) 	 	 (6,15.0)
2 	 (2,5) 	 	 (4,10.0) 	 	 (6,15.0)
2 	 (2,5) 	 	 (4,10.0) 	 	 (6,15.0)
2 	 (2,5) 	 	 (4,10.0) 	 	 (6,15.0)
2 	 (2,5) 	 	 (4,10.0) 	 	 (6,15.0)
2 	 (2,5) 	 	 (4,10.0) 	 	 (6,15.0)
2 	 (2,5) 	 	 (4,10.0) 	 	 (6,15.0)
2 	 (2,5) 	 	 (4,10.0) 	 	 (6,15.0)
2 	 (2,5) 	 	 (4,10.0) 	 	 (6,15.0)
2 	 (2,5) 	 	 (4,10.0) 	 	 (6,15.0)
4 	 (2,5) 	 	 (6,15.0) 	 	 (10,25.0)
4 	 (2,5) 	 	 (6,15.0) 	 	 (10,25.0)
4 	 (2,5) 	 	 (6,15.0) 	 	 (10,25.0)
4 	 (2,5) 	 	 (6,15.0) 	 	 (10,25.0)
4 	 (2,5) 	 	 (6,15.0) 	 	 (10,25.0)
4 	 (2,5) 	 	 (6,15.0) 	 	 (10,25.0)
4 	 (2,5) 	 	 (6,15.0) 	 	 (10,25.0)
4 	 (2,5) 	 	 (6,15.0) 	 	 (10,25.0)
4 	 (2,5) 	 	 (6,15.0) 	 	 (10,25.0)
4 	 (2,5) 	 	 (6,15.0) 	 	 (10,25.0)
6 	 (2,5) 	 	 (8,20.0) 	 	 (14,35.0)
6 	 (2,5) 	 	 (8,20.0) 	 	 (14,35.0)
6 	 (2,5) 	 	 (8,20.0) 	 	 (14,35.0)
6 	 (2,5) 	 	 (8,20.0) 	 	 (14,35.0)
6 	 (2,5) 	 	 (8,20.0) 	 	 (14,35.0)
6 	 (2,5) 	 	 (8,20.0) 	 	 (14,35.0)
6 	 (2,5) 	 	 (8,20.0) 	 	 (14,35.0)
6 	 (2,5) 	 	 (8,20.0) 	 	 (14,35.0)
6 	 (2,5) 	 	 (8,20.0) 	 	 (14,35.0)
6 	 (2,5) 	 	 (8,20.0) 	 	 (14,35.0)
8 	 (2,5) 	 	 (10,25.0) 	 	 (18,45.0)
8 	 (2,5) 	 	 (10,25.0) 	 	 (18,45.0)
8 	 (2,5) 	 	 (10,25.0) 	 	 (18,45.0)
8 	 (2,5) 	 	 (10,25.0) 	 	 (18,45.0)
8 	 (2,5) 	 	 (10,25.0) 	 	 (18,45.0)
8 	 (2,5) 	 	 (10,25.0) 	 	 (18,45.0)
8 	 (2,5) 	 	 (10,25.0) 	 	 (18,45.0)
8 	 (2,5) 	 	 (10,25.0) 	 	 (18,45.0)
8 	 (2,5) 	 	 (10,25.0) 	 	 (18,45.0)
8 	 (2,5) 	 	 (10,25.0) 	 	 (18,45.0)
10 	 (2,5) 	 	 (12,30.0) 	 	 (22,55.0)
10 	 (2,5) 	 	 (12,30.0) 	 	 (22,55.0)
10 	 (2,5) 	 	 (12,30.0) 	 	 (22,55.0)
10 	 (2,5) 	 	 (12,30.0) 	 	 (22,55.0)
10 	 (2,5) 	 	 (12,30.0) 	 	 (22,55.0)
10 	 (2,5) 	 	 (12,30.0) 	 	 (22,55.0)
10 	 (2,5) 	 	 (12,30.0) 	 	 (22,55.0)
10 	 (2,5) 	 	 (12,30.0) 	 	 (22,55.0)
10 	 (2,5) 	 	 (12,30.0) 	 	 (22,55.0)
10 	 (2,5) 	 	 (12,30.0) 	 	 (22,55.0)

Also, j is not used in the code, so maybe there is a typo.

1 Like