Ask Your Question
1

How to enter very large numbers

asked 2014-10-30 15:42:42 +0100

anonymous user

Anonymous

updated 2014-10-30 15:44:23 +0100

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.

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 15:44:47 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-10-30 15:48:18 +0100

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

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 15:42:42 +0100

Seen: 1,029 times

Last updated: Oct 30 '14