Coding to Promote Problem Solving and Logical Reasoning

Ada Lovelace (1815-1852)
Ada Lovelace (1815-1852)

An excellent article, by Scott G. Smith, appeared in the August 2016 edition of MATHEMATICS teacher and published by the National Council of Teachers of Mathematics, got me thinking about how I might use simple coding activities in math classes to promote problem solving and logical reasoning. The author discussed how he used simple coding activities with the TI-84 Graphing Calculator to teach generalization, problem solving and logical reasoning in his algebra 2 classes. Smith provided numerous TI-84 program listings along with explanations.

The purpose of this post is to show how to use an Excel spreadsheet and the TI-BASIC programming language to solve a problem that would be suitable for a high school math class. I chose a spreadsheet solution of the problem because educated adults in a modern economy are expected to have working knowledge of spreadsheets. Then, I chose a TI-84 solution of the problem because programmable calculators are ubiquitous in the modern math classroom.

In a previous post, I discussed algorithms for finding the day-of-week when given a Gregorian or Julian calendar date. If you have not read my post How to Find the Day of the Week for a Given Date, I believe you will find it helpful to read it before continuing because the floor function and mod operator are fully explained. The algorithm for finding the day-of-week given a Gregorian calendar date is given below. This algorithm was also selected for this post because it’s relatively easy to implement in Excel or the TI-BASIC programming language. In my opinion, it’s important that high school students learn the basics of how to use these powerful tools.


The source code of the TI-BASIC program that implements the Gregorian calendar day-of-week algorithm is given below. I indented some lines of code to make the structure of the program easier to understand, but code lines in the TI code editor are left justified. Notice that each line of code starts with character ‘:’ which is automatically inserted by the code editor with each new line of code. After a bit of study, one can easily learn how to translate many algorithms into TI-BASIC code; almost line by line. There are abundant online resources where one can learn how to program in TI-BASIC. In fact, I had to do a bit of research to write this post.


Shown below is the program input and the resulting output after a single run of the TI-BASIC program above. The bold face text is the input the user would enter for the date 12 February 1809. After carefully studying the day-of-week algorithm, the TI-BASIC source code, and a single run of the program, the TI-BASIC code makes perfect sense.


An Excel spreadsheet implementation of the Gregorian day-of-week algorithm is shown below. Note that the text in column B cells of the spreadsheet only serve to clarify what the spreadsheet is about, and to describe what the cells C4 through C13 represent. The spreadsheet formulas (invisible in this view) in cells C7 through C13 generate the numerical and text cell values the user sees. When cells C4, C5 or C6 are changed, cells C7 through C13 are automatically updated.


The reason spreadsheets are so powerful is that cells can contain very complex formulas that determine the numeric or text content of the cell that contains the formula. Shown below are the formulas in cells C7 through C13. I find it fun and interesting to Google a formula that will allow me to easily solve my problem. Notice that the formulas in cells C12 and C13 are broken up into multiple lines, however, formulas in any actual spreadsheet cell are entered as a single continuous string of characters where the first string character is ‘=’.


Some Final Comments, Observations and Suggestions

  • For beginning coders, give students a pseudocode description of an algorithm and then have them implement the algorithm in TI-BASIC or in a spreadsheet. After students learn how to translate statements in an algorithm into computer code, they are ready to start learning how to develop algorithms.
  • Pick problems that relate to their current course work that are relatively easy to solve, but also time consuming and tedious. Students now have a reason to want to learn how to create an algorithm and write code to implement the algorithm.
  • The Common Core Standards for Mathematical Practice do not directly address coding, however, coding activities can certainly help promote the goals of the Common Core Standards.
  • Steve Jobs once said the learning how to program computers is a great way to teach people how to solve problems and reason logically.
  • Coding can become addictive. Years ago, a social studies teacher at my high school reported that parents were complaining that their children were spending too much time outside of class writing Apple Macintosh HyperCard stacks for a social studies class project. The social studies teacher only had to present the project to his class and gave students a short introduction to the coding in the HyperCard language. Students quickly became hooked and simply ran with the project. One class project required over 60 floppy discs to hold the HyperCard stacks!
  • It’s not uncommon to find computer programmers who were music majors in college.
  • Teachers should remind their students that many women have made important contributions to computer science. Ada Lovelace (1815 – 1852), the only legitimate child of the famous poet Lord Byron, was an English mathematician and writer. Around 1843, Ada published an elaborate set of notes that many historians consider to be a description of the first computer program. She also envisioned computers doing much more than just numerical calculations. Rear Admiral Grace Hopper (1906 – 1992), nicknamed “Amazing Grace,” began her career teaching mathematics at Vassar in 1931, and was promoted to associate professor in 1941. In 1934, she earned a Ph. D. in mathematics from Yale. Later she served in the U.S. Navy and other civilian organizations devoted to the development of computer systems and programming languages. Hopper believed computer languages should be similar to the English language rather than the machine language of computers. She made significant contributions to the development of COBOL (COmmon Business-Oriented Language) which is still used in many business applications.

Student Use of Technology in the Classroom

I strongly support the use of technology in the classroom, but of course with some caveats.  In the December 2015/January 2016 issue of MATHEMATICS teacher, published by the National Council of Teachers of Mathematics, NCTM, there were several excellent articles about teaching in a world with technology. The authors of the focus article, Corey Webel and Samuel Otten, discussed using the application PhotoMath in the classroom. PhotoMath is a free application from Apple that works by holding a phone or tablet up to a math equation in a textbook. If the equation is not too complicated, PhotoMath will solve the equation and show the steps to solve the equation. Without going into the pros and cons of each option, I will list the three options the authors considered.

Option 1: Ban Access to PhotoMath
Option 2: Restrict Access to PhotoMath
Option 3: Consider a Different Division of Labor

Option 3 is about how teachers can treat technology as a tool and how tech tools should be used to engage students in ways that promote mathematical reasoning. If applications like PhotoMath are only used to get the right numerical answer, students are being cheated because they are not learning anything of real value. The authors suggested an activity in which students compare PhotoMath’s solution of a linear equation with an intuitive approach to solve the equation.

The purpose of this post is to share some of my thoughts regarding the use of technology in the modern classroom. I make no claim that computer software technology is the grand elixir for solving or fixing the problems of math education. My intention is to provide some ideas as to how software technology should and can be used to enhance math education. Of course, good visuals and physical manipulatives are just as important as ever. I’m looking forward to hearing what readers of this post think about using technology to enhance math education. Please feel free to provide your feedback by replying to this post, commenting on Facebook, or emailing me at

I fondly remember when electronic calculators became widely available in the 1970’s, and later micro computers in the 1980’s. In those early years, it was generally assumed that students and teachers should learn how to program a computer. Eventually it was realized that students and teachers should learn how to use application programs written by professional programmers. I also mention that in the 1980’s in most high schools, student computer access was limited to one or two computer labs and a relatively small number of computers scattered about in a few classrooms. Projection and computer technology is now an important feature of modern classrooms.

My core belief is that all high school math students should eventually understand and memorize a basic set of math facts and relationships before using software technology. Of course, software technology is a wonderful aid for teaching basic math facts. A high school student who needs a calculator to do problems like 8 + 39 or 7 * 9 has been cheated in his/her prior education. A beginning algebra student who needs a calculator to do a simple problem like 27 – 13 is wasting time and energy, and possibly losing some focus on the original problem. In my opinion, only after students have learned a basic set of math facts and relationships is the use of software technology appropriate. Readers can download my free handouts Basic Math Facts and Slope and Equation of Line Summary to use as resource when teaching some of these basic math facts. Some possible inclusions in the basic set of math facts and skills might be the following items:

  • Addition, subtraction, multiplication and division facts
  • Squares of the first 20 counting numbers
  • Cubes of the first 10 counting numbers
  • Powers of 2 such as 25 = 32, 210 = 1,024 and 2-6 = 1/64
  • Decimal equivalent of common fractions such as 5/8 = 0.625
  • Common Pythagorean triples: 3-4-5, 5-12-13, 7-24-25, 8-15-17, 9-40-41 and 11-60-61
  • Properties of real numbers such as the commutative and associative properties
  • The order of operation rules
  • Common polynomial factoring patterns
  • Slope of a line and the different forms of the equation of a linear relationship

After students understand and have memorized a set of basic facts, they should be taught how do a variety of mental math (no paper or calculator) problems. This is important not only to solve common math problems that routinely arise in daily living, but also to develop good estimation skills to see if calculator output is reasonable. Also by learning how to do these types of problems, students will develop a feel for how numbers work. All experienced teachers have stories of students who have given absurd answers that make absolutely no sense. I remember the nationally renowned math educator, Dr. Lola J. May (1923 – 2007), tell her audience, “You can’t teach math to an empty head.” The following examples illustrate some of the types of mental math problems, without hints of course, that I believe most students should eventually be able to handle:

  • 25 * 89 * 4 = ? (Sample problem given in a talk by Dr. Lola May)
  • 57 + 40 + 13 + 8 = ? (Hint: Consider the fact 13 = 3 + 10)
  • 5*$89.95 = ?  (Hint: Consider 5 times ($90 – 1 nickel))
  • Estimate a 15% tip if the bill is $63.58 (Hint: What is 10% of $64.00?)
  • What is the average of 81, 82 and 87? (Hint: What is the average of 1, 2 and 7?)
  • What is the length of the shortest side of a right triangle if the other sides have lengths of 30 and 34?  (Hint: Consider the Pythagorean triple 8 – 15 – 17)
  • Estimate the casualty rate suffered by a regiment if only 47 of 262 survived the battle. (Hint: 50/250 = 1/5 = 20% that were not a casualty)
  • 43*37 = ?  ( Hint: Consider (40 + 3)(40 – 3) = 402 – 32 )
  • The fraction 17/20 is equivalent to what percent? (Hint: How many nickels make a dollar?)
  • Estimate the decimal value of π/12. (Hint: π is close to what integer?)

In order to effectively use technology to teach math in a modern classroom, it’s imperative that all students have ready classroom access to a variety of software tools and physical manipulatives at any time in the classroom. No software tool or physical manipulative alone can teach math, however, teacher guided activities that require student engagement can naturally result positive student benefits. Creating the appropriate teacher guided activity is the hard part. The list below gives the tools that I have used or wished that I had when I taught high school math:

  • Graphing calculator such as the TI 84
  • Logo programming language (Great tool for teaching kids how to think.)
  • Cuisenaire rods (Fantastic physical manipulative for teaching children core math concepts.)
  • Easy to use, yet comprehensive graphing program
  • Easy to use, yet comprehensive probability/statistics simulation program (I can’t image teaching probability theory without a good probability simulation program.)
  • Program to calculate common statistics, confidence intervals, and hypothesis test results
  • Spread sheet program
  • Word processing program
  • Presentation software such as PowerPoint

Some Personal Thoughts Regarding the Use of Technology:

  • Incorporate more history of mathematics and science into math courses. There are abundant online resources that students can use to create interesting PowerPoint presentations relating to a specific history of mathematics and/or science topic. This would be a natural way for students to improve writing skills. (I found the story about Kepler’s laws of planetary motion, and the relationship between Kepler and Tyco Brahe fascinating.)
  • From time to time, have students graph the equations involved in a problem situation, and then check their paper and pencil solution against the graph on the computer screen. When I was tutoring a student several years ago, she asked me how she could show that the graphs of two relations are orthogonal. This involved finding the points of intersection, and then showing that the tangent lines at the points of intersection are perpendicular. I then graphed the relations and tangent lines so that she could better understand what the problem was about; and she did.
  • I envision that the mathematics classroom of the future will be more like a science lab where students have a safe environment to ask questions, use software tools and physical manipulatives to conduct math experiments, and just play around with mathematics. I fully realize that most students are not free spirits in search of truth and are only taking a math course to meet some required course credit. With appropriate teacher guided structured activities, I believe it’s possible to gradually move math education in this direction. Creating the appropriate teacher guided structured activities will take a lot of hard work and sharing of ideas. Will math textbooks of the future primarily contain structured activities for learning math?
  • It’s not necessary to understand all of the mathematics underlying a particular software tool. What’s important is to learn when and how to use the tool and correctly interpret the output generated by the software tool. A master mechanic has a set of tools that he uses to repair cars. The mechanic does not understand the underlying chemistry, physics, mathematics and design principles that allowed the creation of a particular tool, but he knows when and how to use the tool.

I will close this post with a true story about by daughter, Liz. When Liz was a sophomore in college, she asked me if she should take a Mathematica based calculus course. Mathematica was and still is the premier math program in the world. If an engineer, scientist or mathematician has some serious number crunching, any type of symbolic manipulation or data analysis to do, Mathematica is the tool of choice. Mathematica’s ability to create an endless variety of stunning graphic output is mind boggling. I thought that the course would be really cool, so I suggested that she take the course. Liz’s instructor was a knowledgeable user of Mathematica who was a grad student working on a PhD in mathematics. Liz thought that the instructor was a pleasant and likeable person. Students were given Mathematica files relating to the course and were essentially told, “go to it tiger.” Very little explanation was provided as to what concepts the students were supposed to learn by using Mathematica. Liz got an A in the course, but later she told me, “Dad, I feel that the course cheated me.” One student later told me that a Mathematica based calculus course is great if you already understand the course concepts. The point of this story is that no piece of software can teach math without proper and careful teacher guidance.