User Tools

Site Tools


notes:cprog:fall2022:projects:sof0

This is an old revision of the document!


BACKGROUND

This program will focus on a simple mental math trick: calculating the square of a multiple of 5.

This trick works with any multiple of 5 up to three digits (5 to 995), and can be done without much difficult math or a calculator.

Let's take an example number: 105. To calculate the square of 105, we can split the number into two parts, then perform a set of calculations on each part, in order to get our answer.

The two parts we want to split our number into are as follows:

  • The “back” part of the number, which is the 5 at the end of the number (this will be the case for every number).
  • The “front” part of the number, which is the digits before the 5. (In this case, it is 10).

Calculating the back portion is easy, we just need to multiply 5 by itself to get its square:

5 * 5 = 25

To calculate the front portion, we take our number (10), add one to it, and multiply these two values together to get the front portion of the answer:

10 * (10 + 1) = ?
10 * 11 = ?
10 * 11 = 110

Finally, we bring the two portions back together to get our answer:

110 25
11025
105 * 105 = 11025

SPECIFICATIONS

PROGRAM

OUTPUT SPECIFICATIONS

VERIFICATION

In the project files that you grabbed, there is a reference program that you can run to check the output of the program you will be writing, along with the format of the output.

notes/cprog/fall2022/projects/sof0.1663213703.txt.gz · Last modified: 2022/09/15 03:48 by rspringe