Skip to content

Commit ebccfe3

Browse files
committed
feat: add algorithm 95 to find the longest amicable chain
1 parent f4c0a23 commit ebccfe3

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

project_euler/problem_095/sol1.py

+5-21
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
"""
22
Project Euler Problem: https://projecteuler.net/problem=95
33
4-
An amicable chain is a sequence of numbers where each number is the sum of the
5-
proper divisors of the previous one, and the chain eventually returns to the
6-
starting number. The problem is to find the smallest member of the longest
4+
An amicable chain is a sequence of numbers where each number is the sum of the
5+
proper divisors of the previous one, and the chain eventually returns to the
6+
starting number. The problem is to find the smallest member of the longest
77
amicable chain under a given limit.
88
9-
In this implementation, we aim to identify all amicable chains and find the
10-
one with the maximum length, while also returning the smallest member of that
9+
In this implementation, we aim to identify all amicable chains and find the
10+
one with the maximum length, while also returning the smallest member of that
1111
chain.
1212
"""
1313

14-
<<<<<<< HEAD
15-
=======
16-
17-
def sum_of_proper_divisors(number: int) -> int:
18-
"""Calculate the sum of proper divisors of the given number.
19-
>>>>>>> 89e57b63f62908f575161ca2c077f02c189a363c
2014

2115
def sum_of_proper_divisors(n):
2216
"""Calculate the sum of proper divisors of n."""
@@ -34,12 +28,6 @@ def sum_of_proper_divisors(n):
3428

3529
return total
3630

37-
<<<<<<< HEAD
38-
=======
39-
40-
def find_longest_amicable_chain(limit: int) -> int:
41-
"""Find the smallest member of the longest amicable chain under a given limit.
42-
>>>>>>> 89e57b63f62908f575161ca2c077f02c189a363c
4331

4432
def find_longest_amicable_chain(limit):
4533
"""Find the smallest member of the longest amicable chain under a given limit."""
@@ -78,10 +66,6 @@ def find_longest_amicable_chain(limit):
7866
return (
7967
min(longest_chain) if longest_chain else None
8068
) # Return the smallest member of the longest chain
81-
<<<<<<< HEAD
82-
=======
83-
84-
>>>>>>> 89e57b63f62908f575161ca2c077f02c189a363c
8569

8670

8771
def solution():

0 commit comments

Comments
 (0)