diff --git a/coco.py b/coco.py index 0089f4605fb66a5219b8b6628bb6acb33241d4f8..6d53ba861cc146ba3ded58747936dc051fec8a10 100644 --- a/coco.py +++ b/coco.py @@ -1,7 +1,7 @@ #!/usr/bin/env python --""" --Program to solve the 5 men and the coconuts problem --""" +""" +Program to solve the 5 men and the coconuts problem +""" def f(n, n_people=5, remainder=1): @@ -23,9 +23,9 @@ def solve(n_people=5): i = 0 while True: - multiplier = ( - i * (n - 1) + (n - 2)) # This keeps the t_-1 round divisible by 0 - # to reduce the search space + # This keeps the t_-1 round divisible by 0 to reduce the search space + multiplier = (i * (n_people - 1) + (n_people - 2)) + result = f(multiplier * lcm, n_people) for _ in range(n_people - 1): result = f(result, n_people)