You are implementing a function to calculate the factorial of a number. Which Python built-in data type would be most suitable to store the result for very large numbers?

  • Decimal
  • float
  • int
  • long

For very large numbers, the Decimal data type from the decimal module is the most suitable choice. It provides arbitrary-precision arithmetic and can handle extremely large integers without loss of precision. The int type has a limited size, and the float type is not suitable for precise integer calculations. The long type is not a standard Python type; Decimal is the recommended choice for arbitrary precision.

Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *