Hi all,
I have this simple array (p,q) and want to calculate (p1,q1) and (p2,q2) by calculating (p1,q1) first then (p2,q2). The rule is simple pq’ = qp’
I try to create a simple looping here:
# Operations on Rational Numbers for equivalence relation pq' = qp'
p=2
q=5
println("i \t chosen pair \t ordered pair-1 ordered pair-2")
for i = 1:10
p1 = p + i
q1 = (q*p1)/p
for j = 1:10
p2 = p1 + i
q2 = (q1*p2)/p1
println("$i \t ($p,$q) \t \t ($p1,$q1) \t \t ($p2,$q2)")
end
end
The problem is:
I only want to return integer, and my looping is not accurate, I want to list all the possible triplets such as this:
(2,5)≈(6,15)≈(−4,−10)
I try to use if
but it is not working to returns integer:
# Operations on Rational Numbers for equivalence relation pq' = qp'
p=2
q=5
println("i \t chosen pair \t ordered pair-1 ordered pair-2 ")
for i = 1:10
p1 = p + i
q1 = (q*p1)/p
for j = 1:10
p2 = p1 + i
q2 = (q1*p2)/p1
if typeof(p1 && q1 && p2 && q2 == Int64)
println("$i \t ($p,$q) \t \t ($p1,$q1) \t \t ($p2,$q2)")
end
end
end