summaryrefslogtreecommitdiff
path: root/Problem44.py
diff options
context:
space:
mode:
authorJoshua Drake <joshua.drake@ditchwitch.com>2023-04-07 08:13:49 -0500
committerJoshua Drake <joshua.drake@ditchwitch.com>2023-04-07 08:13:49 -0500
commit1161f9a034de06a63538e3a9a0b7717098c744d9 (patch)
tree55bb842b2daa4f096eb7916a8d3630426fc1c376 /Problem44.py
Initial CommitHEADmaster
Diffstat (limited to 'Problem44.py')
-rw-r--r--Problem44.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Problem44.py b/Problem44.py
new file mode 100644
index 0000000..4824b01
--- /dev/null
+++ b/Problem44.py
@@ -0,0 +1,21 @@
+#Works, but is rather slow
+def Pentagon(n):
+ return n*((3*n)-1)/2
+pentagons = []
+for x in range(1,10000):
+ pentagons.append(Pentagon(x))
+count = 1
+run = True
+while (run):
+ for x in range(1,count+1):
+ if pentagons.count(pentagons[count] - pentagons[count-x]) >0 and pentagons.count(pentagons[count] + pentagons[count-x])>0:
+ print(pentagons[count],"|",pentagons[count - x], "\tDifference D is:", abs(pentagons[count] - pentagons[count-x]))
+ run = False
+ #print(pentagons[count] - pentagons[count-x])
+ count+=1
+ pentagons.append(Pentagon(count+9998))
+
+
+
+
+ \ No newline at end of file