Skip to content

Ports - Sopheary#29

Open
sophearychiv wants to merge 2 commits intoAda-C11:masterfrom
sophearychiv:master
Open

Ports - Sopheary#29
sophearychiv wants to merge 2 commits intoAda-C11:masterfrom
sophearychiv:master

Conversation

@sophearychiv
Copy link
Copy Markdown

No description provided.

Comment thread lib/factorial.rb
raise NotImplementedError
return 1 if number == 0
return 1 if number == 1
raise ArgumentError if number == nil
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone put in factorial("2") you'd get an exception. Consider checks such as if number.is_a?(Integer)

Comment thread specs/factorial_spec.rb
factorial(5).must_equal 120
end

it "factorial(3) = 6" do
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition of extra testing!

Comment thread lib/factorial.rb
# Computes factorial of the input number and returns it
# Time complexity: ?
# Space complexity: ?
# Time complexity: O(n) where n is the number
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does time relate to the number?

Comment thread lib/factorial.rb
# Time complexity: ?
# Space complexity: ?
# Time complexity: O(n) where n is the number
# Space complexity: O(1)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain your reasoning for constant space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants