Ask Your Question
1

overflowerror: range() result has too many items

asked 5 years ago

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 .

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered 5 years ago

tmonteil gravatar image

updated 5 years ago

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 ?

Preview: (hide)
link

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

Stats

Asked: 5 years ago

Seen: 1,064 times

Last updated: Jul 08 '19