# Summation

Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0.

For example:
```if-not:racket
~~~
summation(2) -> 3
1 + 2

summation(8) -> 36
1 + 2 + 3 + 4 + 5 + 6 + 7 + 8
~~~
```
```if:racket
~~~racket
(summation 2) ; 3  (+ 1 2)
(summation 8) ; 36 (+ 1 2 3 4 5 6 7 8)
~~~
```

Difficulty: introductory

Starter code:

def summation(num):
	

Solutions:
def summation(num):
    return sum(range(num + 1))
    


def summation(num):
    return (1+num) * num / 2

def summation(num):
    return sum(range(1,num+1))
    


def summation(num):
    return sum(range(num + 1))
    


def summation(num):
    total = 0
    for i in range(0, num+1):
        total = total + i
    return total
    


def summation(num):
    return num*(num+1)//2

def summation(num):
    return num*(num+1) / 2

def summation(num):
    if num > 1:
       return num + summation(num - 1)
    return 1

summation=lambda n:n*-~n>>1

def summation(num):
    fac = 0 
    i = 0 
    while i < num:
        i += 1
        fac = fac + i
    return fac

summation = lambda x: sum(range(1, x + 1))

def summation(num):
    somme=0
    for i in range(num):
        somme+=i+1
    return somme
    pass # Code here

def summation(num):
    sum = 0
    for x in range(1,num+1):
        sum = sum + x
    return sum
    


def summation(num):
    return sum([x for x in range(num+1)])
    


def summation(num):
    ans = 0
    for x in range(1, num):
        ans += x
    return ans + num


def summation(num):
    answer = 0
    for x in range(num):
        answer = answer + num
        num = num - 1    
    return answer
             


def summation(num):
    L=[]
    for i in range(0,num+1):
        L.append(i)
    return sum(L)

def summation(num):
    return sum([n+1 for n in range(num)])


#usr/bin/python

def summation(num):
    result = 0
    for i in range(1, num + 1):
        result += i
    return result
    


def summation(num):
    for i in range(0,num):
        num += i
    return num
    


# https://en.wikipedia.org/wiki/Arithmetic_progression

def summation(num):
    return (num + 1)*num / 2
    


def summation(num):
    if num ==1:
        return 1
    return sum([num,summation(num-1)])
        
    
    


summation = lambda n: n*(n+1)/2


summation  = lambda num: sum([i for i in range(num)], num)#Lambda is fun

def summation(n):
  f = 0
  for i in range(1, n+1):
    f += i
  return f
    


summation = lambda s: sum(range(s+1))

def summation(num):
    if num == 1:
        return 1
    return summation(num-1) + num

def summation(num):
    return sum(range(1, num + 1))


def summation(num):
    ret = 0
    for _ in range(0, num+1):
        ret += _
    return ret

def summation(num):
    
    num_sum = 0

    for i in range(num+1):
        num_sum += i
    
    return num_sum


def summation(num):
     # Code here
    a=0
    for i in range(num):
        a=a+i+1   
    return a
    



def summation(num):
    a = 1
    i = 2
    while i <= num:
        a = i + a
        i += 1
    return a
    


def summation(num):
    i = 0
    while num > 0:
        i = num + i
        num =num - 1
    return i


def summation(num):
    tmp=0
    for j in range(0,num+1):
        tmp=j+tmp
    return(tmp)    


def summation(num):
    sum = 0
    while num > 0:
        sum += num
        num -=1
    return sum

#sum(i for i in a)



def summation(num):
    pass # Code here
    suma = 0
    for i in range(0,num+1):
        suma += i
    return suma
    


def summation(num):
    x = list(range(1,num +1))
    sum = 0
    for i in x:
        sum += i
    return sum
    pass # Code here
    


def summation(num):
    if num<1:
        print("El número debe ser mayor a 0")
    else:
        cont=0
        total=0
        while cont<=num:
            total=total+cont
            cont=cont+1
            
        
        return total
        
        
    


# def summation(num):
#     suma = 0
#     if num == 1:
#         return 1
#     else:
#         for x in (1, num+1):
#             suma = suma + summation(x)
#     return suma
    
    
def summation(num):
    return sum(range(num+1))


def summation(num):
    sum = 0
    x = 1
    while x <=num : 
        sum = sum + x 
        x = x + 1
    return sum
    


def summation(num):
    return sum([i for i in range(num+1)])
            
        # Code here
    


def summation(num):
    sumResult = 0
    while num > 0:
        sumResult = sumResult + num
        num-=1
    return sumResult


def summation(num):
    num1 = 1
    sum = 0
    while num1 <= num:
        sum += num1
        num1 += 1
    return sum
    


def summation(num):
    sum = 0
    x = list(range(num+1))
    
    for n in x:
        sum = sum +n
    return sum


def summation(num):
    
    sum=0
    
    
    for i in range(1,num + 1):
        
        sum = sum + i
        
        pass
    
    
    return sum
    


def summation(num):
    to_return = 0
    n = 0
    while n != num:
        n += 1
        to_return += n
    return(to_return)

def summation(num):
    x = i = 0
    while i <= num:
        x = x + i
        i = i + 1
    return x
    


def summation(num):
    nombre = num
    sum_interm = 0
    while nombre>0:
        sum_interm = sum_interm + nombre
        nombre -= 1
    return sum_interm
        
        
    


def summation(num):
     if num==1:
        return 1
     else:
        return num + summation(num - 1 )# Code here
    
print(summation(6))

def summation(num):
    newNum = 0
    for x in range(num + 1):
        newNum += x
    return newNum
    


def summation(num):
    a = 1
    num = num + 1
    for x in range(1, num): 
        if x < num: a = a + x
    return a - 1

def summation(num):
    
    total = 1
    
    while num != 1:
        total = total + num
        num -= 1
        
    return total

def summation(num):
    a = 1
    for i in range(1, num):
        i = i+1
        a = a + i
    return(a)
    


def summation(num):
    n = list(range(num+1))
    tot = sum(n)
    return tot
    
    


def summation(num):
    accum = 0
    for n in range(1, num+1):
        accum += n
    return accum


def summation(n):
    return(sum(list(range(1, n+1))))

#def summation(n):
#    return(sum([i for i in range(1, n+1)]))


def summation(num):
    a = 0
    for i in range(num):
        a = i + a
    return a + num



def summation(num):
    pass # Code here
    startvalue = 0
    for i in range(0, num + 1):
        startvalue += i
    outvalue = startvalue
    return outvalue


def summation(num):
    return(sum((list(range(0,num+1))))) #range in python 3 is iterator, so needs turning into a list. In P2 it is already a list!
                                        #create range>turn into list>sum it >return it
    


def summation(num):
    summation = (1+num)*num / 2
    return summation


def summation(num):
    x = 0
    for i in range (0, num):
        x = x + num
        num = num - 1
    return(x)
    


def summation(num):
    
    count = 0
    
    x = list(range(num))
    
    for n in x:
        if num > 0:
            count = count + num
            num = num - 1
            
    return (count)
        
    


def summation(num):
    endnumber = 0
    i = 0
    while num >i:
        i +=1
        endnumber +=i
    return endnumber


def summation(num):
    total = 0
    for n in range(0, num + 1, 1):
        total += n
    return total
    


def summation(num):
     # Code here
    suma = 0
    for i in range(1,num+1):
        suma = suma + i
    return suma
    


def summation(num):
    return sum(list(range(num + 1)), 0)
    


def summation(num):
    result = 0
    for k in range(1,num+1):
        result += k
    return result
    


def summation(num):
    counter = 0
    for n in range(1,num+1):
        counter += n
    return counter
    


def summation(num):
    pass 
    i = 0
    rslt = 0
    while i <= num:
        rslt = rslt + i
        i = i + 1
    return rslt
    


def summation(num):
    sum = 0;
    count = 0
    for loop in range(num):
        sum += num - count
        count += 1
        
    return sum
    


def summation(num) -> int:
    return sum(range(1,num + 1))
    


def summation(num):
    # Code here
    result = 0
    for number in range(num+1):
        result += number
    return result
        
    


def summation (num):
  x=num
  if num > 0:
    while x > 0:
      num+=x-1
      x-=1
    return num;
  else:
    return print ("error");


summation (0)

    


def summation(num):
    
    summa = 0

    for i in range (1, num+1):
        
       summa += i
    
    return summa

summation(1)
summation(8)
summation(22)
summation(100)
summation(213)

def summation(num):
    sum = 1
    i = 2
    while(i < num + 1):
        sum += i
        i += 1

    return sum


def summation(num):

    done = sum([x for x in range(1,num + 1)])
    
    return done
                 
    


def summation(num):
    tot = 0
    for n in range(0,num+1):
        tot += n
    return tot

def summation(num):
    num = sum(range(num+1))
    return num
    
    


# def summation(num):
#     result = 0
#     for i in range(1, num+1):
#         result += i
        
#     return result

def summation(num):
    result = 0
    for i in range(num+1):
        print(i, num)
        result += i
    return result

def summation(num, sums=0):
    if num == 0:
        return sums
    else:
        return summation(num-1, sums + num)

def summation(num):
    nr_list = list(range(1, num+1))
    return sum(nr_list)
    
    
        
        
        
        
        
        
        
            


summation = lambda x: sum(list(range(x+1)))

def summation(num):
    return sum(range(num + 1))
print((summation(5)))


def summation(num):

    result = 0
    count = 1

    while count <= num:
        result += count
        count += 1

    return result


def __starting_point():
    assert summation (4)
    

__starting_point()

def summation(num):
    return sum(range(1,num+1))

print((summation(6)))



def summation(num):
    cnt = 0
    for x in range(num+1):
        cnt += x

    return cnt

print((summation(8)))

    


def summation(num):
    return num if num == 1 else sum([i for i in range(num+1)])

def summation(num):
    lone = 0
    for i in range(1, num+1):
        lone = lone + i
    return lone

def summation(num):
    if isinstance(num, int) and num > 0:
        s = 0
        for i in range(num):
            s = s + i
        return s + num 
    else:
        print("No es un número entero positivo")

def summation(num):
    kata_range = []
    for i in range(1, num + 1):
        kata_range.append(i)
    return sum(kata_range)

def summation(num):
    a = []
    for i in range(num+1):
        a.append(i)
    return sum(a)


def summation(num):
    y = 1
    solution = 0
    while y <= num:
        solution += y
        y += 1
    return solution
    


def summation(num):
    res = [i for i in range(num + 1)]
    return sum(res)
    


def summation(num):
    x = 0
    final = 0
    while x <= num:
        final += x
        x += 1
    return final
    


def summation(num):
    return num * (num * 0.5 + 0.5)
    


def summation(num: int) -> int:
    i = 0
    resultado = i

    while i <= num:
        resultado +=i
        i += 1
    
    return resultado

    


def summation(num):    
    number = list(range(1,num+1))
    return sum(number)
    


def summation(num):
    a = []
    [a.append(i) for i in range(0,num+1)]
    return sum(a)
    


def summation(num):
    b = 0
    c = 0
    for i in range(num):
        c+=1
        b+=c
    return b