For loop computing recurrence relation takes very long
<pre><code>Q(x)=[Q(xâ1)+Q(xâ2)]^2
Q(0)=0, Q(1)=1
</code></pre>

<p>I need to find Q(29). I wrote a code in python but it is taking too long. How to get the output (any language would be fine)?</p>

<p>Here is the code I wrote:</p>

<pre><code>a=0
b=1
for i in range(28):
    c=(a+b)*(a+b)
    a=b
    b=c
print(b)
</code></pre>

<p>This WILL take too long, since is a kind of geometric progression which tends to infinity.</p>

<p>Example:</p>

<pre><code>a=0

b=1

c=1*1 = 1

a=1

b=1

c=2*2 = 4

a=1

b=4

c=5*5 = 25

a=4

b=25

c= 29*29 = 841

a=25

b=841

.
.
.
</code></pre>

python loops recurrence