Wrote a python program that added up numbers from 1 to a given number using the Gauss equation. It worked for 100 and 10 but when I do 3 it says the sum is 4 instead of 6. The equation works out in my head, did I mess up the code?
def numberSum(num):
nim = int(num)
num = (nim/2)*(nim+1)
return num
print numberSum(raw_input())