[Python] How to store array of really huge numbers in python?

Discussão em 'Python' iniciado por Stack, Novembro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I am working with huge numbers, such as 150!. To calculate the result is not a problem, by example
    f = factorial(150) is 57133839564458545904789328652610540031895535786011264182548375833179829124845398393126574488675311145377107878746854204162666250198684504466355949195922066574942592095735778929325357290444962472405416790722118445437122269675520000000000000000000000000000000000000.

    But I also need to store an array with N of those huge numbers, in full precision. A list of python can store it, but it is slow. A numpy array is fast, but can not handle the full precision, which is required for some operations I perform later, and as I have tested, a number in scientific notation (float) does not produce the accurate result.

    Edit:

    150! is just an example of huge number, it does not mean I am working only with factorials. Also, the full set of numbers (NOT always a result of factorial) change over time, and I need to do the actualization and reevaluation of a function for which those numbers are a parameter, and yes, full precision is required.

    Continue reading...

Compartilhe esta Página