Retired

Debugging Challenge: Factorial Function with Base Conversion v2 (retired)

Description:

Factorial Function with Base Conversion (v2) - Debugging

In this challenge, you must implement a function that calculates the factorial of a given non-negative integer. The function should also support an optional parameter that allows the user to specify a base for the output.

Requirements:

The function must raise ValueError for negative inputs.

If the base parameter is provided, the function should return the factorial in that base as a string.

If no base is provided, the function should return the factorial in base 10.

The base must be at least 2; otherwise, a ValueError should be raised.

Ensure that the function works efficiently, especially for larger inputs.

The base conversion should properly handle large factorials and return the correct representation.

Additional Considerations:

Handle edge cases such as 0! (factorial of 0) correctly, which should return 1 in any base.

Test cases should cover both valid inputs (positive integers and valid bases) and invalid inputs (negative numbers or invalid bases).

For large inputs, consider the efficiency of the factorial calculation and base conversion.

Identify and fix the bugs in the initial implementation, ensuring that the function works and passes all test cases.

Good luck, have fun!

Stats:

CreatedOct 5, 2024
Warriors Trained10
Total Skips0
Total Code Submissions31
Total Times Completed10
Python Completions10
Total Stars0
% of votes with a positive feedback rating50% of 9
Total "Very Satisfied" Votes4
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes4
Total Rank Assessments8
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • xaatu Avatar
Ad