Entering a very large number

Wolfgang Maier wolfgang.maier at biologie.uni-freiburg.de
Fri Mar 23 08:55:28 EDT 2018


On 03/23/2018 01:30 PM, Wolfgang Maier wrote:
> On 03/23/2018 01:16 PM, ast wrote:
>> Hi
>>
>> I found this way to put a large number in
>> a variable.
>>
>> C = int(
>> "28871482380507712126714295971303939919776094592797"
>> "22700926516024197432303799152733116328983144639225"
>> "94197780311092934965557841894944174093380561511397"
>> "99994215424169339729054237110027510420801349667317"
>> "55152859226962916775325475044445856101949404200039"
>> "90443211677661994962953925045269871932907037356403"
>> "22737012784538991261203092448414947289768854060249"
>> "76768122077071687938121709811322297802059565867")
>>
> 
> A very simple improvement would be to use a single
> triple-quoted string. Assuming you are copy/pasting
> the number from somewhere that will save a lot of your
> time.

Like this, for example:

n = int(
     ''.join("""
37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
91942213363574161572522430563301811072406154908250
23067588207539346171171980310421047513778063246676
89261670696623633820136378418383684178734361726757
28112879812849979408065481931592621691275889832738
44274228917432520321923589422876796487670272189318
47451445736001306439091167216856844588711603153276
70386486105843025439939619828917593665686757934951
62176457141856560629502157223196586755079324193331
64906352462741904929101432445813822663347944758178
92575867718337217661963751590579239728245598838407
58203565325359399008402633568948830189458628227828
80181199384826282014278194139940567587151170094390
35398664372827112653829987240784473053190104293586
86515506006295864861532075273371959191420517255829
71693888707715466499115593487603532921714970056938
54370070576826684624621495650076471787294438377604
53282654108756828443191190634694037855217779295145
36123272525000296071075082563815656710885258350721
45876576172410976447339110607218265236877223636045
17423706905851860660448207621209813287860733969412
""".split())
)




More information about the Python-list mailing list