Integer Overflow in Summing Multiples of 3 and 5
<p>I am sure this question has been ask a lot, but I have checked other forums and have tried addressing the issue, which doesn't seem to help. I am thinking there is an overflow problem, but I can't remember on how to fix it. I took a long break from coding (my fault there) so I am trying some problems to help get me back in the swing of things. So, just wondering as to what is going wrong. When I try <code>n = 1000</code> the answer is wrong but numbers smaller than that seem to work out right. Since large numbers won't work I think it's an integer overflow.</p>

<pre><code>def n_number():
    n = raw_input("Enter a max number: ")
    try:
        int(n)
        return n

    except ValueError:
        print 'Value is not an integer'
        exit(1)

# 'function that will add multiples of 3 and 5 that are less than the given value, n.'
def sum_multiplies(n):
    sum = long(0)
    counter3, counter5 = int(1),int(1)

    value3 = 3*counter3
    value5 = 5*counter5

    while True:
        # 'sums of multiples of 5\'s less than n'
        if value5&lt;int(n):
            sum+= value5
            counter5+=1
            value5 = 5*counter5

        # 'sums of multiples of 3\'s less than n'
        if value3&lt;int(n):
            sum+= value3
            counter3+=1
            value3 = 3*counter3

        else:
            break

    print "sum: %s" %sum
    print "counter3: %s" %counter3
    print "counter5: %s" %counter5

def main():
    'max number is in n'
    n = n_number()

    sum_multiplies(n)

if __name__ == "__main__":
    main()
</code></pre>
