'''
@Author: your name
@Date: 2020-07-30 12:21:21
@LastEditTime: 2020-07-30 13:48:41
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \vscode_py\day24.py
'''
# Question 100
# You are given words. Some words may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification.

# If the following string is given as input to the program:
# 使用list存放无重复的字符串,使用dict存放数量
def Q100():
word_list=[]
word_dict={}
n=int(input("num:"))

for i in range(n):
word=input("time:{},str: ".format(i+1))
if word not in word_list:
word_list.append(word)
word_dict[word]=word_dict.get(word,0)+1

print("len:{}".format(len(word_list)))
for word in word_list:
print(word_dict[word],end=" ")

# Question 101
# 统计字符串中的字母数量
def Q101():
word=input("")
dic={}
for i in word:
dic[i]=dic.get(i,0)+1

# 排序
dct=sorted(dic.items(),key=lambda x:(-x[1],x[0]))
for i in dct:
print(i[0],i[1])


# Question 102
# Write a Python program that accepts a string and calculate the number of digits and letters.
def Q102():
word=input()
a,b=0,0
for i in word:
a+=i.isdigit()
b+=i.isalpha()

print("Digit -",a)
print("Letter -",b)


# Question 103
# Given a number N.Find Sum of 1 to N Using Recursion
def Q103():
n=int(input("n:"))

# method 1
l=[i for i in range(1,n+1)]
ans=sum(l)



print(ans)

# method 2
# 递归
def add_to(n):
if n==0:
return n
else:
return add_to(n-1)+n






if __name__ == "__main__":
# Q100()

# Q101()

# Q102()


# Q103()

n=int(input("n:"))
ans=add_to(n)
print(ans)