Number Juggle 1

This file is part of Timex Sinclair Public Domain Library Tape 1001 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Game

This program is a classic “number mind-reading” trick that guides a player through a sequence of arithmetic operations and then reveals the number they originally thought of. The player is asked to think of a number, double it, add five, subtract seven, and enter the result; the program then recovers the original number using the inverse formula K = (A + 2) / 2. Input is collected via two INPUT statements: one for the player’s name (A$) and one for the computed result (A).


Program Analysis

Program Structure

The program follows a straightforward linear flow with no loops or subroutines. It can be divided into four phases:

  1. Introduction (lines 10–40): Displays a title in inverse video, prompts for the player’s name, and stores it in A$.
  2. Instruction sequence (lines 65–140): Uses CLS and PAUSE 400 to pace three successive on-screen instructions — double it, add five, subtract seven — creating the illusion of a controlled, dramatic reveal.
  3. Calculation and reveal (lines 145–185): Accepts the player’s result as A, computes the original number as K, and displays it.
  4. Save/auto-run footer (lines 300–410): Stops normal execution, then saves the program with an auto-run flag, followed by RUN for re-entry.

The Mathematics

The trick relies on a deterministic arithmetic chain. If the player’s secret number is n, the operations are:

  • Double it: 2n
  • Add five: 2n + 5
  • Subtract seven: 2n + 5 − 7 = 2n − 2

The player types 2n − 2 as A. The program then computes K = (A + 2) / 2, which simplifies to (2n − 2 + 2) / 2 = n, correctly recovering the original number.

Key BASIC Idioms

Several idiomatic patterns appear throughout the listing:

  • The title at line 10 is printed entirely in inverse video using %-escaped characters, a common technique for visual emphasis without machine code.
  • PAUSE 400 (approximately 16 seconds at 50 Hz) is used twice to give the player time to perform the mental arithmetic before the screen is cleared and the next instruction shown.
  • Line 135 uses A$;,,"SUBTRACT SEVEN", placing the instruction text in the third print zone by supplying two commas, creating an indented appearance for variety.
  • Line 75 uses a leading comma (,"DOUBLE IT") to push the text to the second print zone, adding visual alignment.

Variable Usage

VariablePurpose
A$Player’s name, used throughout for personalised prompts
AThe result entered by the player after completing the arithmetic
KThe recovered original number, computed as (A+2)/2

Notable Anomalies

Line numbering is irregular and non-sequential in places (10, 12, 30, 40, 65, 70, 75, 95, 100, …), suggesting the program was edited incrementally with lines inserted between existing ones. There are notable gaps — for instance between lines 185 and 300 — which may indicate deleted or planned content. The STOP at line 300 ensures that the SAVE/RUN block at lines 400–410 is only reached during tape saving, not during normal gameplay execution.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10001 – 10050.

Related Products

Related Articles

Related Content

Image Gallery

Number Juggle 1

Source Code

  10 PRINT "%N%U%M%B%E%R% %J%U%G%G%L%E"
  12 PRINT 
  30 PRINT "NAME OF PLAYER"
  40 INPUT A$
  65 CLS 
  70 PRINT A$;", THINK OF A NUMBER AND"
  75 PRINT ,"DOUBLE IT"
  95 PAUSE 400
 100 CLS 
 120 PRINT A$;",ADD FIVE"
 125 PAUSE 400
 130 CLS 
 135 PRINT A$;,,"SUBTRACT SEVEN"
 140 PRINT "AND TYPE IN THE RESULT"
 145 INPUT A
 150 CLS 
 175 LET K=(A+2)/2
 185 PRINT "YOUR NUMBER, ";A$,",WAS ";K
 300 STOP 
 400 SAVE "1004%7"
 410 RUN 

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

People

No people associated with this content.

Scroll to Top