66
\$\begingroup\$

I am interested in seeing programs which don't ask for any input, print a googol copies of some nonempty string, no less, no more, and then stop. A googol is defined as \$10^{100}\$, i.e., 1 followed by a hundred 0's in decimal.

Example output:

111111111111111111111111111111111111111111111111111111111111111111111111...

or

Hello world
Hello world
Hello world
Hello world
Hello world
Hello world
...

The string can also be entirely composed of white space or special symbols. The only exception to identical copies of a fixed string is if your language decorates the output in some way that can not be prevented, but could be trivially undone in a wrapper script, like prepending a line number to each line. The wrapper script in such cases need not be provided.

You can assume your computer will never run out of time, but other than that, your program must have a reasonable demand of resources. Also, you must respect any restrictions that the programming language of your choice poses, for example, you can not exceed a maximum value allowed for its integer types, and at no point more than 4 GB of memory must be needed.

In other words, the program should in principle be testable by running it on your computer. But because of the extent of this number you will be expected to prove that the number of copies of the string it outputs is exactly 10^100 and that the program stops afterwards. Stopping can be exiting or halting or even terminating due to an error, but if so, the error must not produce any output that could not easily be separated from the program's output.

This is , so the solution with the fewest bytes wins.

Example solution (C, ungolfed, 3768 bytes)

#include <stdio.h>

int main() {
  int a00, a01, a02, a03, ..., a99;
  for(a00 = 0; a00 < 10; a00++)
  for(a01 = 0; a01 < 10; a01++)
  for(a02 = 0; a02 < 10; a02++)
  for(a03 = 0; a03 < 10; a03++)
  ...
  for(a99 = 0; a99 < 10; a99++)
    puts("1");
  return 0;
}
\$\endgroup\$
21
  • 10
    \$\begingroup\$ Consider the sandbox first next time. \$\endgroup\$ – cat Oct 29 '16 at 18:44
  • 9
    \$\begingroup\$ When you post a new question, you are asked to first post it in the sandbox. \$\endgroup\$ – flawr Oct 29 '16 at 18:48
  • 1
    \$\begingroup\$ @KritixiLithos It was toying with that idea but I could not quickly come up with a sample solution. Feel free to make a sequel :-) \$\endgroup\$ – The Vee Oct 29 '16 at 19:16
  • 3
    \$\begingroup\$ @closevoter Are you sure this is too broad? Common sense automatically narrows this down from "print a nonempty string 10^100 times" to "print a character 10^100 times". \$\endgroup\$ – dorukayhan Oct 29 '16 at 23:47
  • 3
    \$\begingroup\$ TIL Googol-1 in Roman numerals \$\endgroup\$ – mbomb007 Oct 31 '16 at 18:36

65 Answers 65

1 2
3
0
\$\begingroup\$

cQuents, 11 bytes

"#10^100::0

Given enough time (and memory, although it times out on TIO instead of running out of output space), will print 10^100 copies of whatever is to the right of 0.

Explanation

"             No join on output
 #10^100      Set n to 10^100
        ::    Print the sequence from 1 to n
          0   Each item in the sequence is 0

Try it online!

\$\endgroup\$
1
  • \$\begingroup\$ Note current version uses & instead of ::, saving 1 byte \$\endgroup\$ – Stephen Feb 1 '19 at 4:54
0
\$\begingroup\$

HadesLang, 3153 bytes

I know this is really bad...but at least I tried, right?

for[num a in range:[0,99]]
for[num b in range:[0,99]]
for[num c in range:[0,99]]
for[num d in range:[0,99]]
for[num e in range:[0,99]]
for[num f in range:[0,99]]
for[num g in range:[0,99]]
for[num h in range:[0,99]]
for[num i in range:[0,99]]
for[num j in range:[0,99]]
for[num k in range:[0,99]]
for[num l in range:[0,99]]
for[num m in range:[0,99]]
for[num n in range:[0,99]]
for[num o in range:[0,99]]
for[num p in range:[0,99]]
for[num q in range:[0,99]]
for[num r in range:[0,99]]
for[num s in range:[0,99]]
for[num t in range:[0,99]]
for[num u in range:[0,99]]
for[num v in range:[0,99]]
for[num w in range:[0,99]]
for[num x in range:[0,99]]
for[num y in range:[0,99]]
for[num z in range:[0,99]]
for[num A in range:[0,99]]
for[num B in range:[0,99]]
for[num C in range:[0,99]]
for[num D in range:[0,99]]
for[num E in range:[0,99]]
for[num F in range:[0,99]]
for[num G in range:[0,99]]
for[num H in range:[0,99]]
for[num I in range:[0,99]]
for[num J in range:[0,99]]
for[num K in range:[0,99]]
for[num L in range:[0,99]]
for[num M in range:[0,99]]
for[num N in range:[0,99]]
for[num O in range:[0,99]]
for[num P in range:[0,99]]
for[num Q in range:[0,99]]
for[num R in range:[0,99]]
for[num S in range:[0,99]]
for[num T in range:[0,99]]
for[num U in range:[0,99]]
for[num V in range:[0,99]]
for[num W in range:[0,99]]
for[num X in range:[0,99]]
for[num Y in range:[0,99]]
for[num Z in range:[0,99]]
for[num aa in range:[0,99]]
for[num ba in range:[0,99]]
for[num ca in range:[0,99]]
for[num da in range:[0,99]]
for[num ea in range:[0,99]]
for[num fa in range:[0,99]]
for[num ga in range:[0,99]]
for[num ha in range:[0,99]]
for[num ia in range:[0,99]]
for[num ja in range:[0,99]]
for[num ka in range:[0,99]]
for[num la in range:[0,99]]
for[num ma in range:[0,99]]
for[num na in range:[0,99]]
for[num oa in range:[0,99]]
for[num pa in range:[0,99]]
for[num qa in range:[0,99]]
for[num ra in range:[0,99]]
for[num sa in range:[0,99]]
for[num ta in range:[0,99]]
for[num ua in range:[0,99]]
for[num va in range:[0,99]]
for[num wa in range:[0,99]]
for[num xa in range:[0,99]]
for[num ya in range:[0,99]]
for[num za in range:[0,99]]
for[num Aa in range:[0,99]]
for[num Ba in range:[0,99]]
for[num Ca in range:[0,99]]
for[num Da in range:[0,99]]
for[num Ea in range:[0,99]]
for[num Fa in range:[0,99]]
for[num Ga in range:[0,99]]
for[num Ha in range:[0,99]]
for[num Ia in range:[0,99]]
for[num Ja in range:[0,99]]
for[num Ka in range:[0,99]]
for[num La in range:[0,99]]
for[num Ma in range:[0,99]]
for[num Na in range:[0,99]]
for[num Oa in range:[0,99]]
for[num Pa in range:[0,99]]
for[num Qa in range:[0,99]]
for[num Ra in range:[0,99]]
for[num Sa in range:[0,99]]
for[num Ta in range:[0,99]]
for[num Ua in range:[0,99]]
for[num Va in range:[0,99]]
out:1
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
end
\$\endgroup\$
3
  • \$\begingroup\$ What is that supposed to be. Do you really need so many for loops. Also if possible provide a link so this can be tested / \$\endgroup\$ – Muhammad Salman Jun 1 '18 at 13:59
  • \$\begingroup\$ @Muhammad Salman Because Hades doesn't have a datatype for BigInts yet. Unfortunatly I can't provide a link to test this :/ \$\endgroup\$ – Azeros Jun 1 '18 at 14:02
  • \$\begingroup\$ Is the language stable and has it been released ? If it is you should probably have it added to TIO. Will make it a lot easier for link providing. \$\endgroup\$ – Muhammad Salman Jun 1 '18 at 14:10
0
\$\begingroup\$

05AB1E, 4 bytes

т°F,

Prints \$10^{100}\$ copies of 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n.

(Don't) try it online.

Explanation:

т     # Push 100
 °    # Pop and push 10^100
  F   # Loop that many times:
   ,  #  And print the top of the stack with trailing newline;
      #  (because the stack and input are both empty, it uses the previous value, which
      #   was the 10^100)

Note: the existing 05AB1E answer uses the legacy version of 05AB1E. In that answer, the Tn could be т to push 100 now as well, but the , won't use the previous value implicitly. (The old version of 05AB1E was built in Python 3, the new version in Elixir.)

\$\endgroup\$
0
\$\begingroup\$

BRASCA, 8 bytes

lH^[ho{]

Try it online! I'm using TIO for this one instead of the JS-based online interpreter cause Python numbers. I recommend running it locally.

Explanation

lH^       - Push 10^100
   [   ]  - While not zero:
    ho{   -   Print codepoint 97 (a) and decrement the counter
\$\endgroup\$
0
\$\begingroup\$

Arturo, 32 bytes

i:10^100while[i>0][dec'i 0print]

Prints the number 0 with a newline a googol times.

\$\endgroup\$
1 2
3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.