• + 1 comment

    Yeah, Python makes this problem pretty trivial

    • + 1 comment

      True, I switched from JavaScript just to get it done.. did find a pitfall though.

      third = math.pow(second, 2) + first
      

      will produce weird numbers from the 8th iteration.

      instead must use: second*second + first

      • + 1 comment

        That's because math.pow() will use floating-point numbers. It is more typically used when the power is a real number, not (necessarily) an integer.

        To raise integers to an integer power, use the exponentiation operator **:

        third = second**2 + first
        

        (Of course to compute a square of x, x*x works just fine as well.)