Just recite a million random numbers. Pi goes on forever. The sequence you recite is bound to be in there somewhere.

Categories: Stupid things


LanthonyS · April 21, 2013 at 6:05 PM

To save time, let’s have Python do it!

import random
i = 0
while i < 1000000:
     print(random.randint(0, 9))
     i += 1

LanthonyS · April 21, 2013 at 6:05 PM

…Indents don’t survive the Wrath of Blog…

S P Hannifin · April 21, 2013 at 8:43 PM

I restored the indents with some HTML trickery…

But there’s a more efficient way…

import random;
int i = random.randint(Math.pow(10,6), Math.pow(10,7)-1);
print i;

LanthonyS · April 23, 2013 at 5:49 PM

Wow! You see, I have only taken a half-credit in Intro to Programming… 🙂

LanthonyS · April 23, 2013 at 5:50 PM

No, wait. Won’t your code just print a random 7-digit number? How will it get a million digits?

S P Hannifin · April 23, 2013 at 6:05 PM

Hahaha… you’re right, whooops… what I meant was…

import random;
int i = random.randint(Math.pow(10,1000000), Math.pow(10,1000001)-1);
print i;

(But the efficiency is tongue-in-cheek, since it wouldn’t work anyway.)

LanthonyS · April 23, 2013 at 7:21 PM

Indeed — adapting that code to Python, it protests a Math.range error 😉

LanthonyS · April 23, 2013 at 7:34 PM

Meanwhile, your blog doesn’t want me to post a million digits. “Error: please type a comment.”

Leave a Reply

Your email address will not be published.