Ask Your Question
1

How to enter very large numbers

asked 10 years ago

anonymous user

Anonymous

updated 10 years ago

vdelecroix gravatar image

Hi,

What is the best way to enter very large integers ( more than a thousand integers) on sage online? I tried to split the number into multiple lines using continuation symbols like \ and ... but nothing works. The horizontal scroll bar is not showing up when i enter the number on a single line. Thanks for your help.

Preview: (hide)

Comments

What do you mean by "sage online" ? Is that the cloud, the Sage notebook or something else ?

vdelecroix gravatar imagevdelecroix ( 10 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 10 years ago

vdelecroix gravatar image

Hello,

I would create a file that contains a number and then read it from Sage. To open a file this is a standard python command (see Input and Output from python.org):

sage: f = open("my_file_that_contains_a_big_number.txt")
sage: text = f.read()
sage: f.close()
sage: my_big_number = ZZ(text)

If it is multiple lines you can remove the breaks with

sage: f = open("my_file_that_contains_a_big_number.txt")
sage: text = f.read()
sage: f.close()
sage: text = text.replace("\n", "")
sage: text = text.replace("\r", "")
sage: text = text.replace(" ", "")
sage: my_big_number = ZZ(text)

Vincent

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: 10 years ago

Seen: 1,056 times

Last updated: Oct 30 '14