From 1161f9a034de06a63538e3a9a0b7717098c744d9 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Fri, 7 Apr 2023 08:13:49 -0500 Subject: Initial Commit --- Problem44.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Problem44.py (limited to 'Problem44.py') 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 -- cgit v1.2.3