a story lives forever
Sign in
Form submission failed!

Stay signed in

Recover your password?
Form submission failed!

Web of Stories Ltd would like to keep you informed about our products and services.

Please tick here if you would like us to keep you informed about our products and services.

I have read and accepted the Terms & Conditions.

Please note: Your email and any private information provided at registration will not be passed on to other individuals or organisations without your specific approval.

Video URL

You must be registered to use this feature. Sign in or register.


Writing a tic-tac-toe program


Learning how to program on the IBM 650
Donald Knuth Scientist
Comments (0) Please sign in or register to add comments

So I learned certain things like, what's… this was a decimal computer, it worked not in the binary system, but in the decimal system, and you had 10-digit numbers, so I… I could learn, so it was also very slow, the division instruction on the machine took 4 milliseconds, that's a, I think it's something like 4 milliseconds, in other words now… now machines go a million times faster. But you know, incredibly slow by… by today's standards, but, so you couldn't do that many divisions per second, and my method of finding prime factors was just to… to try dividing you know, you divide by two? No. Divide by three? No. Divide by four? No. Until you find… until you find a… a factor. So now you take the largest 10-digit number that doesn't have any factors. This… this program would take a long, long, long time. So one of the things I had to do was make it go a little faster. I wouldn't divide by two and three and four and five, I could skip over the even numbers if it's not divisible by two, it's not divisible by four. And… and, you know, I had to do… do things like that in order to… then I, as soon as I got up to a five digit divisor, then I could stop; I didn't know that… I didn't realize that at first, but I didn't have to… to divide by every possible thing, because if it… if it has a divisor at all, the smallest divisor has to be less than the square root of the number you're… you’re looking at, less than or equal. I think I first thought less than, and then I… then I found I had to change my program to less than or equal.

One of the most subtle bugs was, and… and it took me, and it took me a hard time to do it, was… was the following. What if the number had lots and lots of prime factors? Well it turned out there are 10-digit numbers that have, I could only punch eight prime factors on a… on a card, on the answer card, and so I… I would have to prepare my program, because I mean you can have more than 30 prime factors, so I could… so… I had… I had to change my program so that it wouldn't only punch one card as the answer, but it would also punch up to four cards.
So anyway this was… this was, I'm just trying to explain why this little program of finding… of finding prime factors was… was so instructive for me at the time.  And I did it near the end of my freshman year, and… and I was allowed to spend all night sitting at the machine, turning the dials, turning the buttons, and… and Case had an extremely intelligent attitude toward undergraduates. They allowed us to go and touch the computers, do… do everything ourselves, work overnight, sleep in the, you know, in the room, and write programs that would be used by other people on campus. And Stanford had a completely different idea. If you use the computer at Stanford, I learned later, they have a professional staff that would have been, you know… had been sent to them by IBM, of… of scientists who would do the… you would submit the job to them, they would… they would put it through the machine, and you know, you'd… you’d get your answers the next day. Case, all hands on, we are… we are allowed to all that stuff ourselves, and even, they didn't worry that we were going to break the machine, you know, we'd… we’d learned how to open up the… the panels, and… and you know, when papers jams and cards jam, and things like this, or, we could wire the boards and all the stuff. So what if we're freshmen? That's okay. And I think Case and Dartmouth were the only two universities that were so liberal for allowing undergraduates to play with the machines in those days.

Born in 1938, American computing pioneer Donald Knuth is known for his greatly influential multi-volume work, 'The Art of Computer Programming', his novel 'Surreal Numbers', his invention of TeX and METAFONT electronic publishing tools and his quirky sense of humor.

Listeners: Dikran Karagueuzian

Trained as a journalist, Dikran Karagueuzian is the director of CSLI Publications, publisher of seven books by Donald Knuth. He has known Knuth since the late seventies when Knuth was developing TeX and Metafont, the typesetting and type designing computer programs, respectively.

Tags: IBM Model 650, IBM, Case Institute of Technology, Stanford University, Dartmouth College

Duration: 4 minutes, 21 seconds

Date story recorded: April 2006

Date story went live: 24 January 2008