Ask Your Question

Revision history [back]

This is because random.randint(0,3^15-1) returns a Python int and not a Sage Integer. To fix this, you can either

  • convert this int into a Sage Integer, by replacing random.randint(0,3^15-1) with ZZ(random.randint(0,3^15-1))

or

  • ask Sage to directly produce a random Sage integer, by replacing random.randint(0,3^15-1) with ZZ.random_element(0,3^15-1)

This is because random.randint(0,3^15-1) returns a Python int and not a Sage Integer. , and only this latter has a digits method. To fix this, you can either

  • convert this int into a Sage Integer, by replacing random.randint(0,3^15-1) with ZZ(random.randint(0,3^15-1))

or

  • ask Sage to directly produce a random Sage integer, by replacing random.randint(0,3^15-1) with ZZ.random_element(0,3^15-1)

This is because random.randint(0,3^15-1) returns a Python int and not a Sage Integer, and only this latter has a digits method. To fix this, you can either

  • convert this int into a Sage Integer, by replacing random.randint(0,3^15-1) with ZZ(random.randint(0,3^15-1))

or

  • ask Sage to directly produce a random Sage integer, by replacing random.randint(0,3^15-1) with ZZ.random_element(0,3^15-1)ZZ.random_element(0,3^15) Note that in this case, the upper bound becomes excluded by default, so you have to remove the -1.