I need to find the pairs (i,j) and number of pairs for a number N such that the below conditions are satisfied:
1 <= i <= j <= N and also i * i * i = j * j.
For example, for N = 50, number of pairs is 3 i.e., (1,1), (4,8), (9,27).
I tried the below function code but it takes too much time for a large number like N = 10000 or more:
def compute_pairs(N):
pair = []
for i in range (1, N):
for j in range (i, N):
print( 'j =', j)
if i*i*i == j*j:
new_pair = (i,j)
pair.append(new_pair)
print(pair)
return len(pair)