Skip to content

Commit 529e82d

Browse files
committed
1 parent 81bb8f1 commit 529e82d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
def one_to_n(n):
2+
return n*(n+1) /2
3+
def solution(a, b):
4+
'''
5+
1~ 5 합 = 1+2+3+4+5 = 15 : n(n+1) /2 = 5*6/2 = 15
6+
'''
7+
# big , small
8+
if a > b :
9+
n=a ; m=b
10+
elif a < b :
11+
n=b ; m =a
12+
else : # a==b
13+
return a
14+
answer = one_to_n(n) - one_to_n(m-1)
15+
16+
return answer

0 commit comments

Comments
 (0)