Finding "taxiNumber" program, want to exchange nested for loop for optimization reasons
<p>I just started programming 1 week ago so please forgive the chaos you are about to see
I'm trying to find the first x taxi numbers but with my "nested for loop" the program takes ages to go through all possibilities. 
Taxi number:
if there is a number a^3+b^3 that is equal to c^3+d^3
that sum is a taxinumber. Example 
12^3+1^3 == 10^3+9^3 == 1729</p>

<p>For me it's a success if i can find around 20 taxinumber
Thanks beforehand for any tips or tricks! </p>

<p>Here is my code:</p>

<pre><code>import math    

def main():    
    numbersOfResultsToFind = getNumberOfTaxisToFind()
    foundResults = 0
    numberToCheck = 1    
    while(foundResults &lt; numbersOfResultsToFind):
        result = getTaxi(numberToCheck)
        if len(result) &gt; 1: #if more then one a+b
            foundResults = foundResults + 1
            print(numberToCheck, result)
        numberToCheck = numberToCheck + 1

def getNumberOfTaxisToFind():
    return int(input("How many taxinumbers do you want to find? "))                           

def getThirdSquareFloored(value):
    value = value**(1/3)
    value = math.floor(value) #floor value
    return value    

def getTaxi(numberToCheck):
    result = []
    upperLimit = getThirdSquareFloored(numberToCheck)
    for a in range(1, upperLimit+1):
        for b in range(1, upperLimit+1):                                                          
            aCubed = a**3
            bCubed = b**3
            sumCub = aCubed + bCubed            
            if(sumCub == numberToCheck and a &lt; b):
                result.append((a, b))
    return result   

main() 
</code></pre>

<pre><code>import math           

def main():  
    numbersOfResultsToFind = getNumberOfTaxisToFind()
    foundResults = 0
    numberToCheck = 1 
    while(foundResults &lt; numbersOfResultsToFind):
        result = getTaxi(numberToCheck)
        if len(result) &gt; 1:
            foundResults = foundResults + 1
            print(numberToCheck, result)
        numberToCheck = numberToCheck + 1


def getNumberOfTaxisToFind():
    return int(input("How many taxinumbers do you want to find? "))


def getThirdSquareFloored(value):
    value = value**(1./3)
    value = math.floor(value)
    return value   

def getTaxi(numberToCheck):
    result = []
    upperLimit = getThirdSquareFloored(numberToCheck)
    for a in range(1, upperLimit+1):
        b = round((numberToCheck-a**3)**(1./3))
        if(a**3+b**3 == numberToCheck and a &lt; b):
            result.append((a, b))
            if len(result) == 2:
                break
    return result
main() 
</code></pre>

<p>Thanks so much for all help! This is my updated code, runs ALOT quicker. I set the b value to be calculated from a instead of using a nested for loop. I also implemented a if len(result), break in the end of my code
No reason to keep looking for pairs if one is already found</p>

python for-loop nested