Conversation
mmcknett
left a comment
There was a problem hiding this comment.
Nice job! I'd like to see a brief explanation of what n is and why the algorithm is O(n) time complexity.
Checklist
- Clean, working code
- Efficient code - give feedback as you would give to a peer on your team
- A detailed explanation of time and space complexity (explains what n stands for, explains why it would be a specific complexity, etc.)
- All test cases for the assignment should be passing.
| # Computes factorial of the input number and returns it | ||
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: O(n) |
There was a problem hiding this comment.
When you provide time complexity, please explain in a few words what n means. For example, in this case, is n equal to the value of number? Or is it equal to the number of things stored in number (which would be 1)? Or might it have anything to do with the number of decimal digits needed to represent number? It's important to define n for every new problem, since the meaning can change from algorithm to algorithm.
| raise ArgumentError | ||
| end | ||
|
|
||
| i = 1 |
There was a problem hiding this comment.
I'm used to seeing i used as a variable name only when the variable is used to iterate over a collection. This variable is actually being used to accumulate the product of numbers for the factorial calculation. I'd name this something more like product in order to avoid confusion.
| # Time complexity: ? | ||
| # Space complexity: ? | ||
| # Time complexity: O(n) | ||
| # Space complexity: O(1) |
No description provided.