arithmetic
Perform arithmetic calculations
TLDR
Start an arithmetic quiz
Specify one or more arithmetic [o]peration symbols to get problems on them
Specify a range. Addition and multiplication problems would feature numbers between 0 and range, inclusive. Subtraction and division problems would have required result and number to be operated on, between 0 and range
SYNOPSIS
arithmetic [max_number [operator]]
PARAMETERS
max_number
Sets the upper limit for the numbers used in the arithmetic problems. For example, if max_number is 10, problems will involve numbers up to 10 (e.g., 5 + 7). If omitted, defaults to 10.
operator
Specifies the arithmetic operation to drill. Accepted values are + (addition), - (subtraction), * (multiplication), or / (division). If omitted, the default operation is addition (+). When division (/) is selected, arithmetic ensures that only problems with integral results are generated.
DESCRIPTION
The arithmetic command provides a straightforward, interactive drill for practicing basic arithmetic operations. It's designed to help users, especially students, improve their mental math skills in a command-line environment.
Upon execution, arithmetic presents a series of randomly generated math problems based on the specified maximum number and operator. The user types their answer, and the command immediately provides feedback: "Right!" for a correct answer or "What?" for an incorrect one. If the answer is wrong, it prompts the user to try again until the correct answer is entered, at which point it confirms with "Correct!".
It keeps track of the number of questions asked and the number of correct first attempts. At the end of the session, typically when the user interrupts the program, it displays a summary indicating "You got X right out of Y tries." This simple feedback loop makes it an effective tool for quick, no-frills math practice.
CAVEATS
This command is a very basic, text-based utility. It lacks advanced features such as customizable difficulty levels (beyond `max_number`), options for varying problem types within a single session, or persistent scorekeeping. It also does not handle floating-point arithmetic; division problems are specifically designed to yield whole numbers. Its simplicity might be a limitation for users seeking more sophisticated educational tools.
INTERACTIVE GAMEPLAY AND SCORING
The command provides immediate feedback. If an answer is correct, it prints "Right!". If incorrect, it prints "What?" and prompts for another attempt. Once a question is answered correctly (even after multiple tries), it confirms with "Correct!". At the end of the session, it summarizes the user's performance with a line like "You got X right out of Y tries.", where X is the number of problems correctly answered on the first attempt, and Y is the total number of problems presented.
EXITING THE GAME
To quit the arithmetic drill at any point, the user can typically type an interrupt character, which is commonly Control-C (^C) or an end-of-file character, often Control-D (^D).
HISTORY
The arithmetic command is a traditional Unix utility, typically found as part of the bsdgames package on modern Linux distributions. Its origins trace back to early Unix systems, serving as a simple educational game or drill. It exemplifies the early philosophy of providing small, single-purpose tools that are easy to use directly from the command line.