Skip to content

Commit d555a49

Browse files
committed
Merge branch 'patch-12' of git://github.com/SandersLin/Python
2 parents e5f130c + 60ec25e commit d555a49

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

project_euler/problem_12/sol1.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def count_divisors(n):
3030
for i in xrange(1, int(sqrt(n))+1):
3131
if n%i == 0:
3232
nDivisors += 2
33-
33+
#check if n is perfect square
34+
if n**0.5 == int(n**0.5):
35+
nDivisors -= 1
3436
return nDivisors
3537

3638
tNum = 1
@@ -43,4 +45,4 @@ def count_divisors(n):
4345
if count_divisors(tNum) > 500:
4446
break
4547

46-
print(tNum)
48+
print(tNum)

0 commit comments

Comments
 (0)