Ask Your Question
1

How to enter very large numbers

asked 2014-10-30 09:42:42 -0500

anonymous user

Anonymous

updated 2014-10-30 09:44:23 -0500

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.

edit retag flag offensive close merge delete

Comments

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

vdelecroix gravatar imagevdelecroix ( 2014-10-30 09:44:47 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-10-30 09:48:18 -0500

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

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

Stats

Asked: 2014-10-30 09:42:42 -0500

Seen: 286 times

Last updated: Oct 30 '14