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>

<p>The problem is that the <a href="https://en.wikipedia.org/wiki/Taxicab_number" rel="nofollow"><strong>Taxicab numbers</strong></a> are VERY far apart. You can do some math tricks to solve it. For example, you can be checking the <a href="https://en.wikipedia.org/wiki/Euler%27s_sum_of_powers_conjecture" rel="nofollow">Euler's sum of powers</a>. The problem with that approach is that you will be generating some taxi numbers, but they might not be in order.</p>

<p>As it goes to your code, I have some notes:</p>

<ol>
<li>If you want to take the cubic root, do not do <code>value**(1/3)</code>! Remember that <code>1/3 = 0</code> in python. Use <code>1./3</code> or use <code>numpy</code></li>
<li>Don't use the <code>**(1./3)</code> at all - any power functions are expensive, try replacing them with something (precomputed values?)</li>
<li><strong>Important:</strong> <a href="http://stackoverflow.com/questions/11410798/finding-taxicab-numbers">Read StackOverflow if there is a solution already!</a></li>
</ol>

python for-loop nested