Python Forum
Printing googolplex - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Printing googolplex (/thread-9722.html)



Printing googolplex - ThePiMan - Apr-25-2018

Hi. I am trying to write a program that will print the number googol plex (1 followed by a googol(1 followed by 100 zeros)zeros). However, when I run the code the interface is blank. Here is my code:
number_googol="1"
number_googolplex="1"
r_t=0
r_t1=0
zero="0"

while (r_t<100):
    number_googol=number_googol + zero
    r_t=r_t+1
    

while (r_t1<int(number_googol)):
    number_googolplex=number_googolplex + zero
    r_t1=r_t1 +1

if (r_t1 == int(number_googol)):
    print(number_googolplex)
    
     
I encountered no errors trying to run the code.
Can anyone help?


RE: Printing googolplex - mlieqo - Apr-25-2018

it's because your second loop is running googol times and it takes a long time :) I don't think it's possible to print such a large number - https://www.physicsforums.com/threads/how-long-for-a-computer-to-write-out-a-googolplex.690823/


RE: Printing googolplex - Gribouillis - Apr-25-2018

The following program prints googolplex
# python 3 script to print the number googolplex
import sys
w = sys.stdout.write
f = sys.stdout.flush
s = '0' * 100

w('1')
for i in range(10**98):
    w(s)
    f()