The Answer to Life, the Universe, and Everything

Developer(s): Cliff Danielson
Date: 1982
Type: Program
Platform(s): ZX81, TS 1000
Tags: Demo

A joke program for the TS1000 or ZX81, after The Hitchhiker’s Guide to the Galaxy: enter your age and it gives “the answer to life, the universe, and everything”. The answer is 42.

RUN it, enter an age (2 or more), then a friend’s age, and so on. The string A$ holds a formula with the tokens SQR, EXP, PI and **; VAL takes square roots of the age until it is close to 1, and the answer is two digits of EXP (-PI*I). An age of 1 gives 43, and an age below 1 stops the program. It runs in 1K.

Corrected so it runs: line 60 as printed has one closing bracket too few, so the line cannot be entered (and stops with report C if loaded). One “)” is added after (6 TO 12).

The article is unsigned; it is credited to the newsletter’s editor, Cliff Danielson.

Published in the BCS Sinclair-Timex User Group Newsletter December 1982 (The Answer to Life, the Universe, and Everything).

Image Gallery

Source Code

   1 LET A$="I-SQR I>EXP(-PI*I)/PI**2"
  10 PRINT "ENTER YOUR AGE"
  20 INPUT I
  30 CLS
  40 PRINT ,,,,"THE ANSWER TO LIFE, THE UNIVERSE, AND EVERYTHING IS ";
  42 LET I=VAL A$ (3 TO 4)
  50 IF VAL A$ THEN GOTO 42
  60 PRINT (STR$ (VAL A$ (6 TO 12)))(3 TO 4)
  70 PRINT "ENTER A FRIENDS AGE"
  80 GOTO 20

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.