Last active
May 11, 2018 06:24
-
-
Save KojiAomatsu/7c479d91475faac7746781cd7c3f6c0f to your computer and use it in GitHub Desktop.
An exercise for finding beautiful numbers.
This file contains 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
def n22(n): | |
a = 2 | |
b = 2 | |
return n**a+b | |
def calc(): | |
li = [] | |
li2 = [] | |
for i in range(10000): | |
li.append(n22(i)) | |
print("done") | |
for j in range(1,100): | |
j2 = n22(j) | |
for k in range(j,200): | |
k2 = n22(k) | |
l2 = j2*k2 | |
if l2 in li: | |
li2.append([j2,k2,l2,j,k]) | |
li2 = sorted(li2, key=lambda lis: lis[2]) | |
#n^2 + 2型の2つの数の積として表せるn^2 + 2型の数 | |
print(li2) | |
#n^2 + 2型の2つの数の積として2通り以上の方法で表せるn^2 + 2型の数 | |
for i in range(1,len(li2)): | |
if li2[i][2] == li2[i-1][2]: | |
print(li2[i-1], li2[i]) | |
if __name__ == '__main__': | |
calc() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment