Created
September 17, 2013 15:02
-
-
Save adrientetar/6595564 to your computer and use it in GitHub Desktop.
Project Euler #12 in Python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # | |
| # Copyright (C) 2013, Adrien Tétar. All Rights Reserved. | |
| # | |
| def triangleNumber(rank): | |
| res = 0 | |
| for i in range(1, rank+1): | |
| res += i | |
| return res | |
| def sumFactors(triangle): | |
| res = 1 # t%1=0 | |
| for i in range(2, triangle+1): | |
| if (triangle%i == 0): | |
| res += 1 | |
| return res | |
| cur = 0 | |
| while (sumFactors(triangleNumber(cur)) <= 500): | |
| cur += 1 | |
| print(triangleNumber(cur)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment