Skip to content

Instantly share code, notes, and snippets.

@hiterm
Last active June 9, 2016 13:51
Show Gist options
  • Save hiterm/37f1c38671308cd0bc31fdec9c1d5a9b to your computer and use it in GitHub Desktop.
Save hiterm/37f1c38671308cd0bc31fdec9c1d5a9b to your computer and use it in GitHub Desktop.
http://togetter.com/li/875421 の解答(Python3)
import math
n = int(input())
n2 = n * 2
max = math.floor(math.sqrt(n2))
arr = []
for i in range(2, max + 1):
if n2 % i == 0:
j = n2 // i
if i % 2 == 0 and j % 2 == 1:
arr.append((j + 1) // 2 - i // 2)
if i % 2 == 1 and j % 2 == 0:
arr.append(j // 2 - i // 2)
print(sum(arr))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment