To what heights would science now be raised if Archimedes had made that discovery ! Carl Friedrich Gauss (1777-1855) [ about thepositional system of numeration ]
(2002-05-22) [Anonymous query collected by Site's search engine.] If you multiply together all the odd numbers from 1 to 999, what will be the final digit? and why?
The answer is5. As the product of a number ending with 5into any odd number ends in a 5, so does the product of many odd numbers if at least one of them ends in a 5. Let's investigate aslightly less trivial question:
What's the final digit of the product ofall the odd numbersnot divisible by 5 from 1 to 999?
This is an example of what's calledmodular arithmetic:The remainder in the division by some fixedmodulus of a sum, a differenceor a product depends only on the remainders for both operands.Here, themodulus is 10 and eachremainder is simply equal tothe last decimal digit of the number involved.
So, the product of 4 decimal numbers ending with 1, 3, 7 and 9will end with 9. If you multiply together anevennumber of such products, the result ends in a 1 (because the product oftwo factors ending with 9 ends in a 1).
As our product of 400 factors is obtained as the product of 100 such4-tuples, its final digit is thus 1 as well.
How do I find the last [least significant] digits of such huge numbers?
Modular arithmetic is, again, the key: If you want the last 5 digits of a product,use modular arithmeticmodulo 100000.A regular pocket calculator with 10-digit accuracy will give an exact result for theproduct of any pair of two 5-digit numbers, which is what any integer reduces tomodulo 100000. That's all you need to find the last 5 digits of the above productsof 500 or 400 factors. With less modest means, we found that...
The above product of 500 factors ends with:...821809277089697420848324327380396425724029541015625.
The above product of 400 factors ends with:...251632034302682442928182392469846896720096892926001.
What about the leading digits? [most significant digits]
If you want a fewleading digits, as well as the number of digits in the result,the easiest way is to compute thedecimal logarithm of such a huge product as thesum of thedecimal logarithms of its factors.For the 500-factor product, we find a decimal logarithm of 1283.0032378550076961...,corresponding to a 1284-digit number starting with100748329763750854004... For the 400-factor product, we find a decimal logarithm of1026.28235200247947115...,corresponding to a 1027-digit number starting with1915808088370632042699972791343618517...
We may summarizeboth of the above approaches for either product thusly: 500-factor product of 1284 digits: 10074832976375... ...724029541015625. 400-factor product of 1027 digits: 19158080883706... ...720096892926001.
(2013-07-10) It's usually impossible to determine the logarithms of huge numbers.
As discussedabove, modular arithmetic can be used towork out the least significant digits of numbers defined in arithmetical terms. That may remain true even when their decimal lengthsare too large to be described by common methods. For example the last digits of Graham's number are:
...2464195387
What's the leading digit of Graham's number? I don't know and I'm convinced nobody else does either. What's for sure is that the straight logarithmic approach from the previoussection is of no use at all, because the leading digitsof a number are determined by the fractional part of its logarithm. The logarithm of an N-digit number must be known to a precision of at least log N digits for this fractional part to be known at all. In the case of Graham's number, log N is far greater than theinformationthat can be stored in the entire observable universe!
To the best of my knowledge, the only truly huge numbers whose leadingdigits are known have definitions explicitely involving powers of ten. For example, if N is any integer greater than 3 (N could be Graham's number) then the leading digitsof the followingfactored number are 195603290000...
2N . 5N . 19 . 59 . 17449
Iggy(2004-03-31; e-mail) What two integerswithout zero digitshave a product of 1000 000 000 ?
Answer: 512 1953125 = 1000000000.
The first number is the ninth power of 2, the second is the ninth power of 5. This pair is the only [positive] solution,because neither factor could haveboth a 2 and a 5in its prime factorization, or else it would be a multiple of 10 and wouldthus have a 0 as its last digit, which is ruled out.
Generalization :
We may wonder what powers of 10 are products of two integers without any zero digits. For large numbers, this is very unlikely because there will normallybe 10% of zeroes among many random digits... In fact, there seems to beonly 11 possibilities,of which the above is the third largest. Namely:
10 0 = 1 x 110 1 = 2 x 510 2 = 4 x 2510 3 = 8 x 12510 4 = 16 x 62510 5 = 32 x 312510 6 = 64 x 1562510 7 = 128 x 7812510 9 = 512 x 195312510 18 = 262144 x 381469726562510 33 = 8589934592 x 116415321826934814453125
The probability isroughly (0.9)n thatthe nth power of 10 would yield a solution. So, the expected number of solutions above the nth power of 10 isroughly 10 (0.9)n. As we'veactually checked that there's no other solution below n = 1500,we can beextremely confident that the above is all there is (the expected number of remaining solutionsis less than 10-67 ).
(Peter of Portland, OR.2000-10-10) What is the divisibility rule of 13? (D. S. of Hurricane, WV.2000-11-29) What is the divisibility rule for 7?
Recall that a number is divisible by 3 or 9iff the sum of its digits is.
An integer is divisible by 11iff the difference between the sum of its odd digits (units, hundreds,etc.) and the sum of its even digits (tens, thousands, etc.) is so divisible.
The quick tests of divisibility by 7 or 13 are somewhat more complex.Strangely enough, these two are very strongly related (see below for an explanation).The basic process is to form an alternating sum of digits using only every third digit:
From the rightmost digit (the units), you subtract the 4thrightmost (the thousands),add the 7th, subtract the 10th, add the 13th, etc.This gives you the first of three numbers, call it X.
Do the same starting with the second rightmost digit (the tens),subtract the 5th, add the 8th, subtract the 11th, etc.This gives you a second number Y.
Finally, you start with the 3rd rightmost (the hundreds),subtract the 6th,add the 9th, subtract the 12th, add the 15th, etc.This yields a third number Z.
Now, compute the quantity X + 10Y + 9Z, which is best obtained mentallywith just three additions and one trivial multiplication by 10:
10 (Y + Z) + X Z
The original number is divisible by 13iff this quantity is divisible by 13.The original number is divisible by 7 iff this quantity is divisible by 7.
It's remarkable that the same test works for both 7 and 13. The reason is that 713 = 91 = 100-10+1.We're really dealing with divisibility by 91...
To clarify, let's consider any base of numeration B (which may or may not be equal to ten) and use arithmetic moduloM = B2-B+1
(1 mod M) is 1,
(B mod M) is B,
(B2 mod M) is B-1,
(B3 mod M) is M-1 (equivalent to "-1"modulo M, that's the ticket ! )
(B4 mod M) is M-B,
(B5 mod M) is M-(B-1) and
(B6 mod M) is 1,after which the sequence repeats with period 6.
Therefore, using the alternating sums X,Y and Z introduced above in the decimal case, we see that the number whose divisibility by M is being checked differs by a multiple of M from:
X + BY + (B 1) Z = B (Y+Z) + X Z
In the octal system, that divisibility test (based on the quantity X+8Y+7Z) works for 3 and 19, because 3 times 19 is 57 = 82-8+1.
Test of divisibility by 7, for mental computations :
The above method is demonstrably the fastest for large numbers with pencil and paper. For mental computation, however, the necessity of keeping track of several partial resultsis a major roadblock. Also, that method itself is too complicated to memorize without practice, unlike our next one.
Here are the instructions: Split the number N into its last digit y and the number x formed by the other digits (it can be verylarge). Now, consider 2y (twice the digit) and x. Subtract the smaller from the larger. The result is divisible by 7 if and onlyif the original number was. Repeat the procedure until the result is small enoughfor the divisibility to be obvious.
For example, to check that 224 is divisible by seven, subtract twice the last digit (8)from the leading digits (22). You obtain 14. If it's not obvious to youthat 14 is divisible by 7, then do the procedure again; the difference betweentwice the last digit (8) and the leading digit is 7 (that's as low as itcan get, the process always ends up with 0 or 7 for divisible numbers).
A bigger example:
67431 -> 6741 -> 672 -> 63 -> 0
Generalized divisibility tests, for mental computations :
As advertised, we may generalize the above mental test for divisibility by 7 to any modulus M coprime with 10 (which is to say that the last digit of M is 1,3,7 or 9) in which case 10 has a reciprocal d modulo M.
As M and d are coprime (by Bézout's lemma) M divides10x+y if and only if it divides d(10x+y) or, equivalently, if and only if it divides x+dy.
M divides 10 x + y if and only if it divides x + d y
M
d
M
d
M
d
M
d
M
d
M
d
1 3 7 9 11 13 17 19
0 1 -2 1 -1 4 -5 2
21 23 27 29 31 33 37 39
-2 7 -8 3 -3 10 -11 4
41 43 47 49 51 53 57 59
-4 13 -14 5 -5 16 -17 6
61 63 67 69 71 73 77 79
-6 19 -20 7 -7 22 -23 8
81 83 87 89 91 93 97 99
-8 25 -26 9 -9 28 -29 10
101 103 107 109 111 113 117 119
-10 31 -32 11 -11 34 -35 12
When a negative coefficent is called for (e.g., -2 for divisibility by 7) we may discard the sign of the result (since x is divisible if and only if -x is) or, equivalently, state that we'll always subtract the smallernumber from the larger one, as we did in the above recipe for divisibility by 7.
Those tests may end up either in a zero result (which proves divisibility) or a cycle with at least one element whose divisibility is deemedobvious (e.g., when testing 224 for divisibility by 7, we met the cycle 14,7,14,7...)
(John of Middletown, NJ.2000-10-14) Any integer N>0 divides a number whose digitsinclude only 7's and 0's.
Let P be thedecimal period of the number 9N (i.e., digits ultimately repeat with period P in the decimal expansion of 1/9N). We have a relation of the form:
1 / 9N = K / 999...99000...00
Since the number 9N divides the number which consists of P ninesfollowed by a certain number J of zeroes, N divides the number consisting of P ones followed by J zeroes,and also the integer composed of P sevens followed by J zeroes.
The key observation is that, in the process of a long division by thepositive integer D (called denominator or divisor ) you are eventually faced with either a zero remainder or a previously encounterednonzero remainder (since there are only D-1 of those, you can't encounter new ones forever). In the latter case, the sequence of remainders is periodic from that point on...
Because the sequence of digits in the result depends only on the sequenceof remainders, the sequence of digits is ultimately periodic as well. Its period P is called the decimal period of D.
Traditionally, the decimal expansion of a rational number whose period isn't too large is written out by puttinga bar over the sequence of digits that repeat. Usually, the overbar is not allowed to cover any digitsto the left of the decimal point but this usage need notbe respected. Examples:
7526 / 165 = 45.612121212... = 45.6
1 / 7 = 0.
100 / 7 = 14.28571428571428... = 14. =
= 14. = 14.14141414141414... = 1400 / 99
(2012-10-31) (Etienne Midy, 1835) Properties of the period of 1/q in radix-B numeration.
Theperiod described above for decimal numeration generalizesto any numeration radix B. If the period P of q in base B has length n, then we have (assuming q iscoprime with B):
1/ q = P/ (Bn-1)
Therefore, q P = Bn-1 = (B-1) [ 1+B+B2+...+Bn-1] So, if (B-1) is coprime with q, then it must divide P. All told:
Midy's Lemma
B-1 divides the period in base B of any q coprime with B(B-1). (Equivalently, B-1 divides the sum of the B-digits in such a period.)
For example, the decimal period of any integer not divisible by 2, 3 or 5is necessarily divisible by 9. This is to say that thesum of the digits in the decimal period of any such numberis divisible by 9.
Midy's theorem is either the above statement or, more often,one of the following spectacular corollaries (especially the case k=2, which was the only one E. Midy ever bothered with).
A period of length n = k.m may also be construed as a period of length k in base Bm. Therefore, Bm-1 divides the sum of the k slices of m digits that form the whole period of q, whenever q is coprime with B(Bm-1).
For example, the decimal period of 7 is 142857. By viewingthis as a period of length 2 in base 1000, we see that 142+857 must be divisible by 999. If fact, it must be equal to 999 because the next multiple is too big (we leave it to the reader to explain why the sum 999+999 cannot result fromany decimal period of length 6). This is Midy's original statement.
More than a sesquicentury later, Ginsberg would tell us that 14+28+57 must bea multiple of 99 (it's in fact equal to 99).
The smallest acceptable examples (i.e., not divisible by 2,3 or 5) that aren't prime are 49 and 77. The latter is easy:1/77 = 0.
012+987 = 999 01+29+87 = 99 0+1+2+9+8+7 = 3 . 9
49 is more interesting. The period has a length of 42 and it can be dividedinto slices of 21, 14, 7, 6, 3, 2 or 1 digits:
So, what's wrong with the ? Why doesn't it give a multiple of 999999 ? Well, Midy's theorem would only apply if q=49 and (B-1) = 999999 were coprime and they're not (both are divisible by 7).
To prevent such mishaps, the theorem is often stated only for prime values of q. I beg to differ: It's good to know exactly what to look for when dealing with a composite valueof q. This being said, it's true that a prime that doesn't divide B is always OK, sinceit cannot divide Bm-1 for any submultiple m of the period n (otherwise, m itself would be a smaller acceptable period).
It is only by convention that we do not normally use decimal expansionsending with infinitely many nines for numbers that have a terminating decimal expansion (which could also be viewed as ending with infinitely manyzeroes).
Indeed, positional numeration does not yield a one-to-one correspondence betweenthe reals in theinterval [0,1] and the infinite sequences of digits (by appending such sequences tothe "0." prefix). A countable infinity of real numbers are assigned to two sequences of digits. This fact may spoil the beauty ofsome mathematical proofs (most notably Cantor's diagonal argument) but it's really a minor inconvenience which is easily dealt with.
As shown in countless Internet discussions,many beginners seem to have a hard time coming to grips withthis particular idiosyncracy of positional numerations: Different decimal expansions do not necessarily correspondto different numbers. Any number is really the limit of truncated decimal expansions. It so happens that some such limits can be obtained in two different ways.
Real numbers exist independently of the way we choose to represent them. In decimal numeration, the number 1/7 has only onerepresentation. It has two representations in base 7. Namely, 0.1 and 0.0666666... Neither observation is relevant to the fact that the reciprocal of 7 is a unique well-defined point of the real number line.
(S.G. of San Marcos, TX.2000-11-22) How do I represent a floating-point number with hexadecimal normalization?I can't figure out how to convert exponent and mantissa,which should both be expressed in binary.
mrjohngribben(2001-08-10) How would I write a fractional number in a base other than ten? What is pi in hexadecimal (base sixteen)?
You can't "convert" mantissa and exponent separately.Look at the represented number itself andexpress it in binary.
What you want is probably "binary floating-point" (it's certainly possible to have "hexadecimal floating-point",but it's unused in practice).A binary floating-point number may be written out with hexadecimal digitsfor convenience but the exponent still refers to a power of 2 not 16(again,pure hexadecimal is possible, it's just that we don't use it).
Take = 3.14159265... for example.Its first two bits are 1 and 1 (the binary representation of 3),the next bit is the integral part oftwice0.1415926... namely 0.2831853... so it's 0.Repeat the process to get each successive bit by doubling the previous fractional part:You get 0 with 0.56637061...,1 with 1.3127412...,0 with 0.265482457... etc.All told, the (fixed-point) binary representation of is
pi = 11.0010 0100 0011 1111 0110 1...
You may write this in hexadecimal as 3.243F6... if you wish.
What's the binary floating-point representation of ?Well, do just what you would do in decimal:Shift the pattern so there's just one nonzero digit before the "binary" point(resist the temptation to call it a "decimal" point)and record as "exponent" the length of the shift(that's a negative number if you had to shift the pattern to the left).For , you shift the bit pattern only once to the right,so the exponent is +1 and the pattern is
pi = 1.1001 0010 0001 1111 1011 01... (two)^(+1)
That's the proper binary floating-point representation of ("two" is spelled out to avoid using multiple bases of numeration in the same expression,even though "2" would not be ambiguous "16" would be in the discussion that follows).
The commonly usedhexadecimal notation is simply a shorthand for the above,but the exponent still represents a power of two (so the first digit before thefloating point is always a 1 and is therefore actually omitted from many/most/allinternal representations used in computers):
pi = 1.921FA.. (two)^(+1)
What if you wanted everything to use base sixteen? Well, you'd have to shift the bitpattern by a multiple of 4 only (and count one unit of the exponent for each"nybble/nibble" of 4 bits so shifted). For ,this means no shift at all and we have the following purely hexadecimalrepresentation of (I won't repeat it enough, this isnot the one used in computers):
pi = 3.243F6... (sixteen)^(0)
What if you have to convert a large decimal floating point number? Well, like it or not,what you have to do is basically work out the fixed-point representationand express it in binary (or hexadecimal)using a procedure similar to the above. For example, to "convert" 1.965032919280624,just use the above (tedious) procedureto express 19560329.19280624 in binary.
( T. D. of Fairbanks, AK.2000-12-04) How do I find square roots without the use of a calculator,especially when the square root will contain a decimal point? ( J. D. of Cape Coral, FL.2000-12-07) How do I extract the square root of a number?
It works a little bit like a long division with two basic differences:
Instead of one digit at a time, you handle "slices" of two digits at a time (the decimal point separates two such slices).
You get each new digit by trying at each step to "extend"twicethe previously found root with another digit so that the product of this extensionby the (largest possible) new digit does not exceed the previously computedremainder.
To make this clear, let's justcompute the square root of 2:
Remainder is 2,Root is 0,DoubleRoot is 0. The largest digit "?" which is such that "0?" times "?" is no greater than 2 happens to be 1(save this as the first digit in the square root). "01" times "1" is 1,which I subract from 2, the result is 1, which gets augmented by the "next slice"of unprocessed digits, namley "00". So, the newremainder is 100.
Remainder is 100,Root is 1,DoubleRoot is 2. What's the largest digit such that "2?" times "?" does not exceed 100. Well it's 4(save this as the second digit in the root)."24" times "4" is 96, which I subtract from 100 and augment with the next sliceof "00" digits to get 400 as the newremainder.
Remainder is 400,Root is 1.4,DoubleRoot is 28. The largest digit such that "28?" times "?" does not exceed 400 is 1(which is thus our next digit).The new remainder is 400-281=119 augmented by the next "00"; 11900 is the new remainder.
Remainder is 11900,Root is 1.41,DoubleRoot is 282. The next digit is 4 for which "282?" times "?" is 11296. 11900-11296 is 604;new remainder is thus 60400.
Remainder is 60400,Root is 1.414,DoubleRoot is 2828. The next digit is 2 for which "2828?" times "?" is 56564. 60400-56564 is 3836;new remainder is thus 383600.
Remainder is 383600,Root is 1.4142,DoubleRoot is 28284. The next digit is 1 for which "28284?" times "?" is 282841. 383600-282841 is 100759;new remainder is thus 10075900.
Remainder is 10075900,Root is 1.41421,DoubleRoot is 282842. The next digit is 3 ... etc.
Below is a binary version of the above algorithm, implemented (and optimized)in68000 assembly language. One aspect of it is simpler than the above: At each step you onlyhave two choices for what the next (binary) digit is going to be,instead of 10 such choices in the decimal case. Thus, a simple testsuffices (see the BLE instruction below) to make the proper decision...
Such an elementary implementation would allow a 12.66 MHzhandheld calculator to extract over 16000 square roots per second...
; (c) 2007 - Gerard Michon;; SQRT takes a 31-bit integer (z) from register D3; and returns the square root (y) and remainder (x); in D1 and D0 respectively. Upon exit, x+y^2 = z :; D0: 0000 XXXX = Remainder (x); D1: 0000 YYYY = Square root (y); D2: FFFF FFFF = -1; D3: ZZZZ ZZZZ = Argument (z) unchanged;; BSR SQRT = 752 cycles + twice the count of '1' bits in y.; Min=752, Max=784 (with 18 cycles for BSR instruction).;; Time: (in clock cycles);7000 SQRT MOVEQ #0,D0 4: Clear x7200 MOVEQ #0,D1 4: Clear y7400 MOVEQ #0,D2 4: Two 16-bit counters5E42 AGAIN ADDQ.W #7,D2 4: Branch 7 times, for 8 loops4843 SWAP D3 4: Deal with upper 16 bits first3003 MOVE.W D3,D0 4: Fetch 16-bit sliceEFC0 LOOP ROL.L #2,D0 12: Get 2 more radicand bitsD241 ADD.W D1,D1 4: Shift root one bitB041 CMP.W D1,D0 4: OK to set root's new bit?6F02 BLE SKIP 10: No, leave 0 bit as is5241 ADDQ.W #1,D1 2: Time = 4-2 (branch not taken)51C2 SKIP DBRA D2,LOOP 10: Decrement counter (8 times)FFF2 4:4842 SWAP D2 4:4A42 TST.W D2 4: Already been here?67E6 BEQ AGAIN 10: No, do second half4E75 RTS 14: Time = 16-2 (branch not taken)
Warning : A Numericana reader couldn't make the above work... Unfortunately, I no longer can test that program or even debugit step by step on paper (having missplaced the proper Motorola documentation).
(2009-10-14) From odometers to guessing cards and automated phone help.
A mechanical radix-b odometer consists of n wheels,each engraved with b symbols (representing the digits from 0 to b-1). Such a device can encode b n different integers,thus conveying anamount of information equal to
n lg(b)
Therefore, the amount of information per engraved symbol is lg(b)/b. If b=2, this is 0.5 Sh (a fancy way to say that there are two engraved symbols per bitin a binary odometer). The lower quantity lg(10)/10 = 0.33219... Sh indicates that a decimal odometer is less efficient than a binary one according to a theoretical "cost" proportional tothe total number of engraved symbols. On the other hand, surprisingly,a ternary odometer (b = 3) is 5.66% more efficient than a binary one, since lg(3)/3 = 0.52832... Sh.
That slight advantage of the ternary system of numeration waspondered at the beginning of the computer era. However, the above analysis assumes thatan element capable of encoding a trit (i.e., a ternary digit) is only 50% more costlythan its binary counterpart. If a ternary element is at least 58.49% more costly than a binaryone (which is the case for all electronic solutions devisedso far) then the putative advantage is lost... All modern computers are binary.
The above gave birth to theurban legend that ternary numeration was the "best" onesince the integer 3 is "closest to the optimum" [sic] of e = 2.718281828... (which maximizes the aforementioned quantity lg(b)/b).
Nevertheless, I argue that the marginal superiority of ternary numerationcan be put to good use in at least one entertaining example: A definiteimprovementon the popular "age card" guessing trick.
(2012-12-18) Counting in base twelve. Reviving ounces, dozens and grosses.
The uncia was the basic Roman fraction. Twelve unciae per unit. The roman ounce wasone twelfth of a Roman pound. Likewise 12 ozt (i.e.twelvetroy ounces) used to make a troy pound (the lbt unit wasmade illegal for any trade in 1879 but the ozt remains a dominant unitof mass worldwide for precious metals).
There is, of course, no way any other positional system will everreplace the decimal system for general use (our computers"think" in binary but communicate with people in decimal). Yet, some people are having fun advocating the duodecimal (radix twelve) positional system of numeration and the new nomenclature that couldaccompagny its everyday use:
The name dozenal for the system itself.
Two extra digits dek () & el () for ten & eleven, respectively.
The abbeviations do, gromo for the first powers of twelve.
(2018-09-26) Cuneiform numbers were ultimately upgraded with a zero placeholder.
Originally, no cuneiform mark existed for the zero sexagesimal digit, which was just represented by a blank space. Spacing was also critical when a sexagesimal digit with only a symbol for tenswas followed by a sexagesimal digit with no tens. Thus, there was a great risk of confusion between the sexagesimal numberswhich we're now transliterating (unambiguously) as 56 and 50.06 (the ancient scribe who produced Plimpton 322 made that very mistake on his second row).
The need for several kinds of zeros:
Stand-alone zero. Nothing to count. The Void.
Radix point and leading zeros. Initial zeros.
Terminal cipher, Trailing zeros. Final zeros.
Medial Cipher. Empty intermediate position. Zero sexagesimal digit.
Lack of ones. Completing the digits for 10, 20, 30, 40 and 50.
By 300 BC, a double slanted line (sometimes superscripted) evolved into a true zero sexagesimal digit, which could serveeither as a medial or terminal cipher (trailing zeros indicatingmultication into a power of sixty).
Apparently, that cuneiform symbol was never used by itself historically. The number zero was invented in India several centuries after cuneiform writingwas utterly extinct.