1
1
"""
2
2
Project Euler Problem: https://projecteuler.net/problem=95
3
3
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
7
7
amicable chain under a given limit.
8
8
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
11
11
chain.
12
12
"""
13
13
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
14
20
15
21
def sum_of_proper_divisors(n):
16
22
""" Calculate the sum of proper divisors of n ."""
@@ -28,6 +34,12 @@ def sum_of_proper_divisors(n):
28
34
29
35
return total
30
36
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
+ > >> >> >> 89e57 b63f62908f575161ca2c077f02c189a363c
31
43
32
44
def find_longest_amicable_chain (limit ):
33
45
"""Find the smallest member of the longest amicable chain under a given limit."""
@@ -66,6 +78,10 @@ def find_longest_amicable_chain(limit):
66
78
return (
67
79
min (longest_chain ) if longest_chain else None
68
80
) # Return the smallest member of the longest chain
81
+ < << << << HEAD
82
+ == == == =
83
+
84
+ >> >> >> > 89e57 b63f62908f575161ca2c077f02c189a363c
69
85
70
86
71
87
def solution ():
0 commit comments