Due to another of his misbehaved, 
the primary school's teacher of the young Gauß,  Herr J.G. Büttner, to keep the bored and unruly young schoolboy Karl Friedrich Gauss busy for a good long time, while he teaching arithmetic to his mates,
assigned him the problem of adding up all the whole numbers from 1 through a given number `n`.

Your task is to help the young Carl Friedrich to solve this problem as quickly as you can; so, he can astonish his teacher and rescue his recreation interval.

Here's, an example:

```
f(n=100) // returns 5050 
```

It's your duty to verify that n is a valid positive integer number. If not, please, return false (None for Python, null for C#).

> **Note:** the goal of this kata is to invite you to think about some 'basic' mathematic formula and how you can do performance optimization on your code. 

> Advanced - experienced users should try to solve it in one line, without loops, or optimizing the code as much as they can.

-----

**Credits:** this kata was inspired by the farzher's kata 'Sum of large ints' . In fact, it can be seen as a sort of prep kata for that one.

Difficulty: introductory

Starter code:

def f(n):
	

Solutions:
def f(n):
    return n * (n + 1) // 2 if (isinstance(n, int) and n > 0) else None


def f(n):
    return sum(range(1, n + 1)) if type(n) is int and n > 0 else None

def f(n):
    try:
        return None if n <= 0 else sum(range(1,(n+1)))
    except:
        return None

def f(n):
    return ((n+1)/2)*n if isinstance(n,int) and n > 0 else None

def f(n):
    return None if type(n) != int or n < 1 else n*(n+1)/2

def f(n):
    return (n + 1) * n //2 if (type(n) is int and n>0) else None

def f(n):
    return n*(n+1)//2 if (isinstance(n,int) and n>0 ) else None

from functools import reduce
def f(n):
    return None if not isinstance(n, int) or n<1 else reduce(lambda x, y: x + y, range(1, n + 1))

def f(n):
    try:
        x = int(n)
        if int(n) < 0:
            return None
        elif int(n) > 0:
            return sum([i for i in range(0, n+1)])
        
    except:
        None
    #pass


from numbers import Number
def f(n):
    return n*(n+1)/2 if isinstance(n, int) and n > 0 else None

f = lambda n: (n**2+n)//2 if type(n)==int and n>0 else None

def f(n):
   return (isinstance(n,int) and n>0) and n*(n+1)/2 or None

f = lambda n: (n/2)*(n+1) if type(n) == int and n>0 else None

f = lambda n: n * (n + 1) / 2 if type(n) is int and n > 0 else None

def f(n):
    return (n * (n + 1)) >> 1 if isinstance(n,int) and n > 0 else None

def f(n):
    return n*(n+1)/2 if isinstance(n, int) and n > 0 else None

def f(n):
    if isinstance(n, int) and n >= 1:
        return (n / 2) * (n + 1)
    else: 
        return None

def f(n):
    return int((((n**2)-1) + (1+n))/2) if isinstance(n, int) and n > 0 else None

def f(n):
    if isinstance(n,int) == True and n > 0:
        return int((n*(n+1))/2)
    else:
        return None

def f(n):
    try:
        if n > 0 and type(n) is int:
            return int((n*(n+1))/2)
    except:
        return None

def f(n):
    if type(n) == int and n >0:
      return (1+n)*n/2
    elif type(n) == str or type(n) == float or n < 0:
      return None
    else:
      return None

def f(n):
    if isinstance(n,int):
        if n>0:
            sum=0
            for i in range(0,n+1):
                sum = sum +i
            return sum    
    return None

def f(n):
    if type(n)!=int:
        return None
    return sum([x for x in range(n+1)]) if n>0 else None

def f(n):
    n_ = None
    try:
        n_ = float(n)
    except:
        return(None)
    
    return(n_*(n_+1)/2 if (n_.is_integer() and n_ > 0) else None)

def f(n):
  try: 
    if n > 0:
      return sum(range(1, n+1))
  except:
    return None

def f(n):
    try :
        if n%1 == 0 and n > 0: 
           return  (sum(range(0,n+1,1))) 
        else: return None
    except TypeError:
        return None

def f(n):
    try:
        x = int(n)
        if int(n) < 0:
            return None
        elif int(n) > 0:
            return sum([i for i in range(0, n+1)])
        
    except:
        None

def f(n):
    if type(n) is not int or n <= 0:
        result = None
    else:
        lst = [i for i in range(0,n+1)]
        result = sum(lst)
    return result

def f(n):
    if(type(n) != int):
        return None
    if (n>0): 
        return n*(n+1)/2
    return None

def f(n):
    if type(n)==int and n>0:
        return sum([x for x in range(n+1)])
    else:
        return None

def f(n):
    tot = 0
    if type(n) == int and n > 0:
        for number in range(1, n + 1):
            tot += number
        return tot
    return None

def f(n):
    if isinstance(n, int) and n > 0:
        nn = [i for i in range(n+1)]
        return sum(nn)

#    sum = 0
#    if isinstance(n, int):    
#        if n > 0:
#            for i in range(n+1):
#                sum += i
#            return sum
#        return None
#    else:
#        return None


def f(n):
    if type(n) == str or type(n) == float or n < 1:
        return None
    return sum(range(1, n+1))

def f(n):
    return None if type(n) in [str, float] or n < 1 else sum([i for i in range(0, n+1)])

def f(n):
    try:
        return n*(n+1)/2 if n>0 and (n - round(n) == 0) else None
    except TypeError:
        return None

def f(n):
    if isinstance(n,int) and n>0: return n*(n+1)/2

def f(n):
    if isinstance(n, int) and n > 0:
        return n * -~n >> 1

def f(n):
    if type(n) == int and n > 0:
        return (n/2)*(n+1)

def f(n):
    return n*n/2 + n/2 if type(n) is int and n > 0 else None

def f(n):
    if type(n) == int and n > 0: return sum(range(1, n + 1))

f=lambda n:int==type(n)and n>0and-~n*n/2or None

def f(n):
    if type(n) is int:
        if n > 0:
            return n * (n + 1) / 2
        else: 
            return None
    else: 
        return None

def f(n):
    if type(n) == float or type(n) == str or n == 0 or n <= -1:
        return None
    else:
        return sum([elem for elem in range(0, n + 1)])

def f(n):
    # 1 + 2 + 3 + n-2 + n-1 + n 
    # 1+n + 2+n-1 + 3+n-2 + ...
    if type(n) is int and n >= 1:
        number_of_elements = n / 2
        total_elements = (n + 1) * number_of_elements
        return total_elements
    else: 
        return None


def f(n):
    print('The number is' + str(n))
    if n == 1:
        return n
    if type(n) != int or n <= 0:
        return None
    return (n / 2) * (n+1)

def f(n):
    return sum(list(range(0, n+1))) if isinstance(n, int) and n > 0 else None


def f(n):    
    return sum(i for i in range(int(n) + 1)) if isinstance(n, int) and n > 0 else None


def f(n):
    if type(n) is int and n>0:
        return int(n*(n+1)/2)
    else:
        return None
        


def f(n):
    if type(n) == type(1) and n > 0:
        return (1 + n)*n/2
    else:
        return None

def f(n):
    if type(n) == int and int(n) > 0:
        return (n+1)*n/2

def f(n):
    try:
        val = int(n)
        if val <= 0:
            return None
    except ValueError:
        return None
    else:
        i = 0
        nums = []
        while i < n:
            if type(n) != int:
                return None
            else:
                i+=1
                nums.append(i)
        return sum(nums)


f = lambda n: (1+n) * n // 2 if type(n) == int and n > 0 else None

def f(n):
    n = n
    total = 0
    if type(n) != int:
        return None
    if n <= 0:
        return None

    while n >=0:
        total +=n
        n-=1
        
    return total
    



def f(n):
    try:
        int(n)
        if n <= 0:
            return None
        else:
            return sum(range(n+1))
    except:
        return None


def f(n):
    if isinstance(n, int) == True:
        sum = 0
        if n > 0:
            for i in range(n + 1):
                sum +=i
            return sum
        else:
            return None
    else:
        return None

def f(n):
    if isinstance(n,str):
        return None
    if n <=0:
        return None
    if n!=int(n):
        return None
    
    return   n*(n+1)//2

def f(n):
    if isinstance(n, str):
        return None
    if isinstance(n, float):
        return None
    if n <= 0:
        return None
    count = 0
    for i in range(n+1):
        count += i
    
    return count

def f(n):
    if isinstance(n, int) and n > 0:
            sum = 0
            while int(n) > 0:
                sum += n
                n -=1
            return sum
    return None


def f(n):
    total = 0
    if isinstance(n, int) and n > 0:
        for b in range(0, n+1, 1):
            total = total+b
        return total
    else: 
        return None


def f(n):
    
    return sum(range(1,n+1,1)) if str(n).isdigit() and int(n) > 0 else None

def f(n):
    if isinstance(n, int) == False or n <= 0:
        return None
    else:
        sum = 0
        for i in range(1, n+1):
            sum += i
        return sum


def f(n):
    sum = 0
    #isinstance(n, int) is asking that n isinteger
    if isinstance(n, int) == True:
        if n > 0:
            for i in range(n):
                i = i + 1
                sum += i
            return sum
        #if n<=0
        else:
            return None
        
    #if False
    else:
        return None


def f(n):
    sum = 0
    if isinstance(n, int) == True:
        if n > 0:
            for i in range(n):
                i = i + 1
                sum += i
            return sum
        else:
            return None
    else:
        return None


def f(n):
  if not isinstance(n, int): return
  result = 0
  for x in range(n + 1):
    result += x
  return result if result > 0 else None

def f(n):
    if isinstance(n , int) and n > 0:
        return int((n/2)*(1+n))

def f(n):
    sum=0
    if type(n)==int:
        if n<=0:
            return None
        for x in range(n+1):
            sum=sum+x
        return sum
    else:
        return None
    pass

def f(n):
    if type(n)!= int:
        return None
    if n <= 0 :
        return None
    else:
        
        return sum([i for i in range((n)+1)])


def f(n):
    if not type(n) == int or not n > 0:
        return
    else: 
        result = (n+1) * (n/2)
    return result

def f(n):
    
    if isinstance(n, int) and n >0:

        return (1/2)*n*(n+1)
    
    else:
        
        return None

def f(n):
    if type(n) == str:
        return None
    elif n < 0:
        return None
    if type(n) == float:
        return None
    if n == 0:
        return None
    suma = 0
    for i in range(n+1):
        suma+=i
    return suma

def f(n):
    if type(n) != int or n < 1:
        return None
    else:
        return (n * (n+1)) / 2

def f(n):
    try:
        if n > 0:
            return sum(range(0, n+1))
        else:
            return
    except:
        return


def f(n):
    try:
        return sum(range(n+1)) if sum(range(n+1)) else None
    except:
        return None

def f(n):
    if type(n) == int and n>0:
        a =0
        sum = 0
        while a < n:
            a = a + 1
            sum = sum + a
        return sum

def f(n):
    if isinstance(n, int) and n > 0:
        return sum(x for x in range(1, n+1))

def f(n):
    if type(n) == int:
        counter = 0
        if n > 0:
            for i in range(n + 1):
                counter += i
        
        if counter > 0:
            return counter
        else:
            return None
    
    return None

def f(n):
    if type(n) != int:
        return None
    if n <= 0:
        return None
    if n == int(n):
        return 0.5 * n * (n + 1)
    else:
        return None

def f(n):
    if isinstance(n, int) == True and n>0:
        return sum(range(0,n+1))

def f(n):
    return (n /2)*(1+ n) if type(n) ==int and n>0 else None

def f(n):
    print(n) 
    if isinstance(n, int) and n > 0:
        x = 0
        y = 0
        while x <= n:
            y += x
            x += 1 
        return y
    else:
        return None

def f(n):
    if type(n) is not int or int(n) <= 0:
        return 
    else:
        return (n*(n+1))//2 
    


def f(n):
    if type(n)==int:
        if n >0:
            return sum(range(n+1))
    else:
        return None


def f(n): return sum([x for x in range(n+1)]) if isinstance(n,int) and n>=1 else None

from math import factorial
def f(n):
    if type(n) != int: 
        return None
    else:
        if n<=0: 
            return None
        p=0
        for k in range(1,n+1):
            p+=k
        return p



def f(n): 
    if isinstance(n,int) and n>0: return sum(range(0,n+1))
    


def f(n):
    if isinstance(n, int) and n > 0: return sum(range(1+n))

def f(n):
    if isinstance(n, int) and n > 0: return sum([a for a in range(0,n+1)])


def f(n):
    if isinstance(n, int) and n > 0:
        return sum([a for a in range(0,n+1)])
    else:
        return None

def f(n):
    if isinstance(n, int) and n > 0:
        return (n*(2+(n-1)))/2 if n > 0 else None

def f(n):
    if isinstance(n, int) != True or n <= 0:
        return None
    else:
        if n == 1:
            return 1
        else:
            return (1 + n) * (n / 2)

def f(n):
    if isinstance(n,int) and n>=1:
        return n*(n+1)/2
    else: return None

def f(n):
    if isinstance(n, int)==True and n>0:
        return sum(list(range(0,n+1)))
    else:
        None

def f(n):
    x = []
    if type(n) == int and int(n) > 0:
        n = abs(n)
        for i in range(1,n + 1):
            x.append(i)
        return (sum(x))
    else:
        return None

def f(n):
    if isinstance(n,int) == True:
        if n > 0:
            sum = 0
            for num in range(0, n+1, 1):
                sum = sum+num
            return sum
        else:
            None
    else:
        return None
            
        


def f(n):
    if type(n) == int and n > 0:
      num = 0
      for i in range(n+1):
         num += i
      return num  

def f(n):
    print(n)
    return (n)*(n+1)//2 if (isinstance(n, int) and n>0) else None