Ask Your Question

overflowerror: range() result has too many items

asked 2019-07-08 10:12:37 +0200

Hassan Mostafa gravatar image

i am working with elliptic cure NIST p-521. i am trying to do loop with the syntax " for i in range (n): ". but n is too large for ex: n= 6864797660130609714981900799081393217269435300143305409394463459185543183397653210140554620662074004704518954203785444253993810126864972419532086575239231303.

which give the error

overflowerror: range() result has too many items .

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-07-08 11:34:45 +0200

tmonteil gravatar image

updated 2019-07-08 11:35:04 +0200

You can try by replacing range which:

  • produces a list (hence should be first filled with all those numbers, which is impossible anyway)
  • relies on C longs to work (and your number is too large for that)

with xsrange that

  • is an iterator (the x)
  • relies on Sage integers (the s)

That said, you should understand that there is no hope to exhaust all, or even a reasonable part of those numbers. Even if the computation you are doing ineach loop costs one nanosecond, how long will the total computation be ?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2019-07-08 10:12:37 +0200

Seen: 991 times

Last updated: Jul 08 '19