Skip to content

Commit b5490c4

Browse files
committed
SPOJ Problems
1 parent 7a0438f commit b5490c4

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Please compute the sum of squares for the given numbers: a, a+1, ..., b-1, b.
2+
#
3+
# Input
4+
#
5+
# Two numbers: a and b separated by space, where 1 <= a <= b <=100.
6+
#
7+
# Output
8+
#
9+
# Computed sum: a*a + (a+1)*(a+1) + ... + (b-1)*(b-1) + b*b
10+
#
11+
# Example
12+
#
13+
# Input:
14+
# 1 4
15+
# # Please compute the sum of squares for the given numbers: a, a+1, ..., b-1, b.
16+
#
17+
# Input
18+
#
19+
# Two numbers: a and b separated by space, where 1 <= a <= b <=100.
20+
#
21+
# Output
22+
#
23+
# Computed sum: a*a + (a+1)*(a+1) + ... + (b-1)*(b-1) + b*b
24+
#
25+
# Example
26+
#
27+
# Input:
28+
# 1 4
29+
#
30+
# Output:
31+
# 30
32+
# Example 2
33+
#
34+
# Input:
35+
# 5 6
36+
#
37+
# Output:
38+
# 61
39+
# Output:
40+
# 30
41+
# Example 2
42+
#
43+
# Input:
44+
# 5 6
45+
#
46+
# Output:
47+
# 61
48+
49+
a, b = map(int, input().split())
50+
result = 0
51+
for i in range(a, b + 1):
52+
result += i*i
53+
print(result)

0 commit comments

Comments
 (0)