-
-
Save pqcfox/56a7889f962eafbae22d to your computer and use it in GitHub Desktop.
An exercise in my Number Theory class.
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
| import math | |
| square_tri = [] | |
| def tri(n): | |
| return n*(n+1)/2 | |
| k = 1 | |
| while len(square_tri) < 4: | |
| val = math.sqrt(tri(k)) | |
| print(int(val)) | |
| print(val) | |
| if val == int(val): | |
| square_tri.append(tri(k)) | |
| k += 1 | |
| print(square_tri) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment