For project Euler problem 21, I am trying to implement Thabit's theorem, obtaining the PQR values with this function:
def getPQR(n):
pqr = []
p = (3 * 2^(n - 1) - 1)
pqr.append(p)
q = (3 * 2^n) - 1
pqr.append(q)
r = (9 * 2^((2*n) - 1) - 1)
pqr.append(r)
return pqr
For n = 2, the function should return [5, 11, 71]
, but it instead returns [6, 3, 16]
Any help as to what I'm missing would be greatly appreciated! Thank you!