Skip to content

Commit

Permalink
fix: ✏️ decrease the number of lines
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewLawendy committed Aug 1, 2023
1 parent 7826c0c commit a8178f3
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
def count_steps(conjecture_steps, number):
if number <= 1:
return conjecture_steps
return count_steps(
conjecture_steps + 1, number * 3 + 1 if number % 2 else number / 2
)

def steps(number):
def steps(number, conjecture_steps = 0):
if number < 1:
raise ValueError("Only positive integers are allowed")

return count_steps(0, number)
if number == 1:
return conjecture_steps

return steps(number * 3 + 1 if number % 2 else number / 2, conjecture_steps + 1)

0 comments on commit a8178f3

Please sign in to comment.