Writing a program that finds perfect numbers - error
<p>I'm working on a program that finds perfect numbers (i.e., 6, because its factors, 1, 2, and 3, add up to itself). My code is</p>

<pre><code>k=2
mprim = []
mprimk = []
pnum = []

def isprime(n):
    """Returns True if n is prime."""
    if n == 2:
        return True
    if n == 3:
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False

    i = 5
    w = 2

    while i * i &lt;= n:
        if n % i == 0:
            return False

        i += w
        w = 6 - w

    return True

def mprime(k):
    while k &lt; 50:
        check = (2**k)-1
        if isprime(check) == True:
            mprim.append(check)
            mprimk.append(k)
            print check
            k+=1
        else:
            k+=1

mprime(k)

def isperf(lst):
    for i in lst:
        prm = (((2**i)-1)(2**i))/(2)
        pnum.append(prm)

isperf(mprimk)

print pnum
</code></pre>

<p>The first part, that checks if a number is prime, and produces <em>mercenne primes</em>, is working alright. Its the second part I'm having trouble with. I have read that if <code>2^k - 1</code> is prime, then <code>((2^k - 1)(2^k))/2</code> is a <em>perfect number</em>, so I am using that formula. </p>

<p>The error it gives is </p>

<pre><code>Traceback (most recent call last):
  File "python", line 47, in &lt;module&gt;
  File "python", line 44, in isperf
TypeError: 'int' object is not callable
</code></pre>

<p>Line 47 is <code>isperf(mprimk)</code> and line 44 is <code>prm = (((2**i)-1)(2**i))/(2)</code>. Any assistance would be appreciated. </p>

<p>Thanks!</p>

<p>The error clearly states that you are trying to call an int type, which isn't callable. </p>

<p>In practice it means you trying to do something like <code>123()</code></p>

<p>And code responsible for it is <code>((2**i)-1)(2**i)</code> because you forgot <code>*</code> and it should be <code>(((2**i)-1)*(2**i))/(2)</code></p>

python math compiler-errors listiterator