Math is properly classified as a humanity. How I came to it.

Wondering if your 7-digit phone number is prime? Click here to download the program, "sieveOfEratosthenes.exe".

Don't worry. I wrote it virus-free, in a C++ class at North Central Michigan College in Petoskey in 2002.

It will factor any number up to 7999999, which includes most phone numbers.

It uses an algorithm developed by Eratosthenes of Cyrene, a Libyan mathematician of the third century BC. No one has ever improved on it.

Run the program, wait for it load, and enter any number up to the limit.

After a moment the screen will display the number's prime factors. As a bonus, it identifies those which are palindromes. (Palindromes, like 181 and 77377, are the same forward and backward.) It saves the information to a text file "eratosthenes.txt", which appears when you exit the program in the same folder with the program. The text file also has statistics about your number.

Exit the program by entering -1.

Here is a program for arithmetic operations on integers up to +/- 100 billion trillion quadrillion.

A number that large can be hard to visualize, but it becomes clear if you think how many millimeters it would be to go from here to the edge of the observable universe and back a billion times.

Calculators and computers have visualization problems too. They can only count to 4 billion. It's a scandal, but "selfProvingArithmeticOperations.exe" solves it for most numbers.

Click here to download it.

Actually, there are numbers higher than 100 billion trillion quadrillion. Scientists at North Central Michigan College have identified them, and an enumeration program is in development. Investors contact the author.

In the program, you are asked to enter any two integers ("operands") up to 38 digits in length. The program will give you their sum, difference, product, and quotient with remainder, even if the answer is over 38 digits.

As a bonus, it also proves the answers by "casting out 9's." That is, after figuring an answer it repeatedly sums the digits of the two operands ending up with two single digits, does the operation on the two digits, and compares the result to the sum of the digits of the answer. Qed.

Casting out 9's is a result-checking trick within the grasp of ordinary sixth-grade math students. It originated in the first millennium in India. Fibonacci published it in Pisa in 1202, and today he is honored by a statue next to the leaning tower.

How does it work? Try adding the digits of a +/- integer and repeating in like manner until a single digit is reached. If the single digit is 9 or -9, add -9 or 9 to make it zero. Finally, if the single digit is negative, add 9 to change it to a single positive integer.

For example:

9866 -> 29 -> 11 -> 2
-168 -> -15 -> -6 -> 3
-1657488 -> -39 -> -12 -> -3 -> 6
9 -> 0

Each end result is the same digit you get if you repeatedly subtract +/- 9 from the number you started with. Hence the name "casting out 9's".

A few minutes of figuring will convince you this is true in every case. Now, by hand or with a calculator, see that the product 9866 * (-168) = (-1657488). As shown above, this is mirrored by the operation 2 * 3 = 6, proving the calculator is correct. There are similar proofs if you add or subtract 9866 and (-168). (A calculator works with these numbers because they are small.)

Division is a little trickier, since you have to take account of the remainder. When you divide (-168) into 9866 the quotient is

-58 -> -13 -> -4 -> 5

and the remainder is

122 -> 5 .

In any division problem, the divisor times the quotient plus the remainder always equals the dividend. Mirroring this formula using the substitute digits, casting out 9's gives you:

( 3 * 5 ) + 5 -> 20 -> 2 .

But recall from above that

9866 -> 2 .

The two digits (both = 2) are the same, so the division answers ( -58 and 122 ) are correct. A few more minutes of figuring will convince you that these proofs hold for any pair of operands.

Actually, casting out 9's is not a 100% proof. It can give false corrects, typically when digits are accidentally transposed. 8 * 13 = 401 is false and 8 * 13 = 104 is true, yet casting out 9's would show both to be correct.

The better proof is to work out the operations by hand, and then check and re-check your work. By-hand operations with 38-digit numbers are enjoyable if you have the stamina and the time and are also obsessed. But casting out 9's never gives false incorrects, and unlike data entry mistakes arithmetic mistakes are rarely the result of transpositions. So casting out 9's is a good second choice.

Casting out 9's, reprise

This trick for checking arithmetic is a curious and fortunate result of our customary base-10 number system. There are actually two concepts involved.

The first is that the sum of the digits of a number is the same as what you get if you repeatedly subtract 9 from the number. Repeating the process if necessary will bring you to a single digit from 0 to 8. Consider for example the numbers 31 and 428. These and all other numbers can be analyzed the following way:

 31 =  30     + 1
=  3 x 10     + 1
=  3 x (9 + 1)     + 1
= (3 x 9) + (3 x 1)   + 1
= (3 x 9) +  4    

In other words if you subtract 9 from the original number 3 times you end up with 4, which is the sum of the digits of the original number, 31.  Again:

428 =  400   + 20     + 8
=  4 x 100   + 2 x 10     + 8
=  4 x (99 + 1)   + 2 x (9 + 1)     + 8
= (4 x 99) + (4 x 1) + 2 x 9 + (2 x 1)   + 8
= (4 x 9 x 11) + (4 x 1) + 2 x 9 + (2 x 1)   + 8
= (44 x 9) + (4 x 1) + 2 x 9 + (2 x 1)   + 8
= (44 x 9)   + 2 x 9 + (2 x 1) + (4 x 1) + 8
= (44 + 2 ) x 9     + 2 + 4 + 8
= (46 x 9 ) + 14.          

In other words if you subtract 9 from the original number 46 times you end up with 14, which is the sum of the digits of the original number, 428.  But since 14 has two digits, subtract 9 from it to obtain 5.  Note that 1 + 4 = 5.  So the single digit for 428 is 5.

You will see the calculation is in many cases even easier than this, because you are allowed to ignore any 9's, or pairs or triples of digits summing to 9, when doing the digit summing.  Thus, try working through the numbers 9034 or 23648 the same way as above, and then work them through again ignoring the 9 in 9034 and ignoring the 3+6 in 23648; in each case you end up with the same single digit.

If you begin with a negative number, instead of subtracting 9's, add +9 until you reach a single positive digit.

Are the end-result single digits the same as what you would get if you repeatedly subtracted, say, 17 or 8 or some other number?  No, although 3 has interesting properties similar to 9.

Algebraists call 9 the "modulus" and a number's resulting single digit the number's "remainder modulo 9." If the number is n, the remainder modulo 9 is abbreviated to "n mod 9".  Arithmetic can be done on the remainders modulo 9, which mirrors arithmetic done on original numbers.

This is called "modular arithmetic," and this mirroring is the second concept involved in casting out 9's.  Consider subtraction.  Can you say in every case that if a - b = c, then ( a mod 9 ) - ( b mod 9 ) = ( c mod 9 )?  Yes.  Try the numbers above.  By definition:

      5 = 428 mod 9
      4 =   31 mod 9


 5 - 4 = (428 - 31) mod 9 ?

It does, because as above,

  428 = (47 x 9) + 5,


     31= (3 x 9) + 4


  397 = (47 - 3) x 9 + 1,
= (44) x 9 + 1

which means

     1 =  397 mod 9.

Work through these examples using other numbers, and then try working through examples of multiplication, addition, and division.  You will find the checking procedure consistently works.

Beware though. As noted above, it does not always work the other way.  In other words, if ( a mod 9 ) - ( b mod 9 ) = ( c mod 9 ), it is not necessarily true that a - b = c.

There are many treatments of casting out 9's.  Sometimes called "the Hindu check," it was first published in the west in 1202 by the merchant and scholar, Leonardo Fibonacci of Pisa.  It is thought variously to have originated in India in 950 and with the Pythagoreans in 325 AD. See for instance:

Casting out nines and elevens
Casting out nines
Casting out nines
Fibonacci's Liber Abaci (Book of Calculation)
Casting out nines

General Algorithm for Extracting Approximate Square Roots

A few years back I was wondering if the algorithm we all learned in 6th or 7th grade, for extracting square roots of numbers with pencil and paper, was really right. it turns out that it is. Here's why.

Unique Factorization by Prime Ideals

I wrote a paper my senior year in college. It got me an NSF fellowship tenable at any university in the free world, which I took at the University of Chicago in 1966. (I left after a year.)

Some definitions:

  • The integers are all the whole numbers, positive and negative, together with zero. Notice that if you add or multiply any two integers you get an integer. Accordingly addition and multiplication are the integers' two "operations." Subtraction is not a separate operation; it is just the inverse of addition. What about division? Division is not an operation. There are millions of examples of pairs of integers such that, when you divide them, the answer is not an integer.

  • The rational numbers are the set of all quotients of integers, such as 1/2, 3/1, 3/2, 0/6, 275057024/24557456747, etc, and their negatives. Exception: zero is not allowed as a denominator.

  • An algebraic integer is a complex number that is a root of some monic polynomial (leading coefficient 1) with integer coefficients.

  • A finite algebraic number field is a generalization of the rational numbers.

  • A ring is a generalization of the integers and its familiar operations.
  • An ideal is a generalization of the set, typically, of multiples of an integer; such as the set of all even numbers. As with integers, ideals can be multiplied, and an ideal can be either prime or composite.

This paper elaborates the notion, due to Dedekind, that every ideal in the ring of algebraic integers in a finite field extension of the rational numbers can be factored uniquely into prime ideals, even though there is no unique factorization of the elements in the ring.

Here it is: Unique Factorization of Ideals in Finite Algebraic Number Fields, Honors Paper, Math Department, Bowdoin College, 1966.

Celestial Navigation / Spherical Geometry

Electronic tools having advanced so far in reliability and ease, celestial navigation cannot be justified today on practical grounds. The naval academy was right in 1998 to discard it as a required course. Even when done well, it yields only approximate results. As one letter-writer to the New York Times said it that year, the most useful function of a sextant and a slide rule aboard a lifeboat today is as paddles.

Sailors study it today for a different reason. We appreciate the history of inquiry and the beauty of the celestial sphere. We sail among the stars to sense connections with our environment and our past.

But do we study well? Students of celestial navigation generally are not shown proofs of the geometric relations among the parts of the navigational triangle. Rather they are encouraged to use, though not to understand, tables in books to solve their sightings. The result is unsatisfying and obstructive and -- given that only 11th-grade level math is involved -- unnecessary.

This paper, written in 1999 for a local chapter of the Power Squadron, corrects that error. In the process it demonstrates the general solution of an arbitrary spherical triangle given any three of the six parts. As background, an appendix proves the theorem of Pythagoras and various trigonometric relations.

Download Derivation of Trigonometric Sight Reduction And Sailings: An 11th-Grade View.


I work KenKen puzzles daily. Here is a 9x9 I completed in 2016. It took a couple of days. Now it's faster. I completed "hard" 9x9 # 43095 in 22:40.