home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / puzzles / archive / arithmetic / part2 < prev   
Encoding:
Internet Message Format  |  1996-04-27  |  22.4 KB

  1. Received: from MIT.EDU (PACIFIC-CARRIER-ANNEX.MIT.EDU [18.69.0.28]) by bloom-picayune.MIT.EDU (8.6.13/2.3JIK) with SMTP id AAA22904; Sat, 27 Apr 1996 00:40:54 -0400
  2. Received: from [199.164.164.1] by MIT.EDU with SMTP
  3.     id AA26996; Sat, 27 Apr 96 00:36:29 EDT
  4. Received: by questrel.questrel.com (940816.SGI.8.6.9/940406.SGI)
  5.     for news-answers-request@mit.edu id VAA20194; Fri, 26 Apr 1996 21:37:30 -0700
  6. Date: Fri, 26 Apr 1996 21:37:30 -0700
  7. X-Mail-Submission-From: chris@questrel.questrel.com (Chris Cole)
  8. Message-Id: <199604270437.VAA20194@questrel.questrel.com>
  9. To: news-answers-request@MIT.EDU
  10. Reply-To: chris@questrel.questrel.com
  11. Newsgroups: rec.puzzles,news.answers,rec.answers
  12. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!spool.mu.edu!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!questrel!chris
  13. From: chris@questrel.com (Chris Cole)
  14. Subject: rec.puzzles Archive (arithmetic), part 04 of 35
  15. Message-ID: <puzzles/archive/arithmetic/part2_745653851@questrel.com>
  16. Followup-To: rec.puzzles
  17. Summary: This is part of an archive of questions
  18.  and answers that may be of interest to
  19.  puzzle enthusiasts.
  20.  Part 1 contains the index to the archive.
  21.  Read the rec.puzzles FAQ for more information.
  22. Sender: chris@questrel.com (Chris Cole)
  23. Reply-To: archive-comment@questrel.com
  24. Organization: Questrel, Inc.
  25. References: <puzzles/archive/Instructions_745653851@questrel.com>
  26. Date: Wed, 18 Aug 1993 06:04:29 GMT
  27. Approved: news-answers-request@MIT.Edu
  28. Expires: Thu, 1 Sep 1994 06:04:11 GMT
  29. Lines: 556
  30. Xref: senator-bedfellow.mit.edu rec.puzzles:24990 news.answers:11510 rec.answers:1910
  31.  
  32. Archive-name: puzzles/archive/arithmetic/part2
  33. Last-modified: 17 Aug 1993
  34. Version: 4
  35.  
  36.  
  37. ==> arithmetic/digits/squares/three.digits.p <==
  38. What squares consist entirely of three digits (e.g., 1, 4, and 9)?
  39.  
  40. ==> arithmetic/digits/squares/three.digits.s <==
  41. The full set of solutions up to 10**12 is
  42.               1 ->                            1
  43.               2 ->                            4
  44.               3 ->                            9
  45.               7 ->                           49
  46.              12 ->                          144
  47.              21 ->                          441
  48.              38 ->                         1444
  49.             107 ->                        11449
  50.             212 ->                        44944
  51.           31488 ->                   9914 94144
  52.           70107 ->                  49149 91449
  53.         3 87288 ->               14 99919 94944
  54.       956 10729 ->          9 14141 14499 11441
  55.      4466 53271 ->        199 49914 44949 99441
  56.     31487 17107 ->       9914 41941 99144 49449
  57.   2 10810 79479 ->    4 44411 91199 99149 11441
  58.  
  59. If the algorithm is used in the form I presented it before, generating
  60. the whole set P_n before starting on P_{n+1}, the store requirements
  61. begin to become embarassing. For n>8 I switched to a depth-first
  62. strategy, generating all the elements in P_i (i=9..12) congruent to
  63. a particular x in P_8 for each x in turn. This means the solutions
  64. don't come out in any particular order, of course. CPU time was 16.2
  65. seconds (IBM 3084).
  66.  
  67. In article <1990Feb6.025205.28153@sun.soe.clarkson.edu>, Steven
  68. Stadnicki suggests alternate triples of digits, in particular {1,4,6}
  69. (with many solutions) and {2,4,8} (with few). I ran my program on
  70. these as well, up to 10**12 again:
  71.               1 ->                            1
  72.               2 ->                            4
  73.               4 ->                           16
  74.               8 ->                           64
  75.              12 ->                          144
  76.              21 ->                          441
  77.              38 ->                         1444
  78.             108 ->                        11664
  79.             119 ->                        14161
  80.             121 ->                        14641
  81.             129 ->                        16641
  82.             204 ->                        41616
  83.             408 ->                      1 66464
  84.             804 ->                      6 46416
  85.            2538 ->                     64 41444
  86.            3408 ->                    116 14464
  87.            6642 ->                    441 16164
  88.           12908 ->                   1666 16464
  89.           25771 ->                   6641 44441
  90.           78196 ->                  61146 14416
  91.           81619 ->                  66616 61161
  92.         3 33858 ->               11 14611 64164
  93.      2040 00408 ->         41 61616 64641 66464
  94.      6681 64962 ->        446 44441 64444 61444
  95.      8131 18358 ->        661 16146 41166 16164
  96.     40182 85038 ->      16146 61464 66146 61444  (Steven's last soln.)
  97.   1 20068 50738 ->    1 44164 46464 46111 44644
  98.   1 26941 38988 ->    1 61141 16464 66616 64144
  99.   1 27069 43631 ->    1 61466 41644 14114 64161
  100.   4 01822 24262 ->   16 14611 14664 16614 44644
  101.   4 05784 63021 ->   16 46611 66114 66644 46441
  102.  78 51539 12392 -> 6164 66666 14446 44111 61664
  103. and
  104.               2 ->                            4
  105.              22 ->                          484
  106.             168 ->                        28224
  107.             478 ->                      2 28484
  108.            2878 ->                     82 82884 (Steven's last soln.)
  109.      2109 12978 ->         44 48428 42888 28484
  110. (so the answer to Steven's "Are there any more at all?" is "Yes".)
  111.  
  112. The CPU times were 42.9 seconds for {1,4,6}, 18.7 for {2,4,8}. This
  113. corresponds to an interesting point: the abundance of solutions for
  114. {1,4,6} is associated with abnormally large sets P_n (|P_8| = 16088
  115. for {1,4,6} compared to |P_8| = 5904 for {1,4,9}) but the deficiency
  116. of solutions for {2,4,8} is *not* associated with small P_n's (|P_8|
  117. = 6816 for {2,4,8}). Can anyone wave a hand convincingly to explain
  118. why the solutions for {2,4,8} are so sparse?
  119.  
  120. I suspect we are now getting to the point where an improved algorithm
  121. is called for. The time to determine all the n-digit solutions (i.e.
  122. 2n-digit squares) using this last-significant-digit-first is essentially
  123. constant * 3**n. Dean Hickerson in <90036.134503HUL@PSUVM.BITNET>, and
  124. Ilan Vardi in <1990Feb5.214249.22811@Neon.Stanford.EDU>, suggest using
  125. a most-significant-digit-first strategy, based on the fact that the
  126. first n digits of the square determine the (integral) square root; this
  127. also has a running time constant * 3**n. Can one attack both ends at
  128. once and do better?
  129.  
  130. Chris Thompson
  131. JANET:    cet1@uk.ac.cam.phx
  132. Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk
  133.  
  134. Hey guys, what about
  135.  
  136. 648070211589107021 ^ 2 = 419994999149149944149149944191494441
  137.  
  138. This was found by David Applegate and myself (about 5 minutes on a DEC 3100,
  139. program in C).
  140.  
  141. This is the largest square less than 10^42 with the 149-property; checking
  142. took a bit more than an hour of CPU time.
  143.  
  144. As somebody suggested, we used a combined most-significant/least-significant
  145. digits attack.  First we make a table of p-digit prefixes (most significant
  146. p digits) that could begin a root whose square has the 149 property in its
  147. first p digits.  We organize this table into buckets by the least
  148. significant q digits of the prefixes.  Then we enumerate the s digit
  149. suffixes whose squares have the 149 property in their last s digits.  For
  150. each such suffix, we look in the table for those prefixes whose last q
  151. digits match the first q of the suffix.  For each match, we consider the p +
  152. s - q digit number formed by overlapping the prefix and the suffix by q
  153. digits.  The squares of these overlap numbers must contain all the squares
  154. with the 149 property.
  155.  
  156. The time expended is O(3^p) to generate the prefix table, O(3^s) to
  157. enumerate the suffixes, and O(3^(p+s) / 10^q) to check the overlaps (being
  158. very rough and ignoring the polynomial factors) By judiciously chosing p, q,
  159. and s, we can fix things so that each bucket of the table has around O(1)
  160. entries: set q = p log10(3).  Setting p = s, we end up looking for squares
  161. whose roots have n = 2 - log10(3) digits, with an algorithm that takes time
  162. O( 3 ^ [n / (2 - log10(3)]) ), roughly time O(3^[.66n]).  Compared to the
  163. O(3^n) performance of either single-ended algorithm, this lets us check 50%
  164. more digits in the same amount of time (ignoring polynomial factors).  Of
  165. course, the space cost of the combined-ends method is high.
  166.  
  167. -- Guy and Dave
  168. -- 
  169. Guy Jacobson              School of Computer Science
  170. Carnegie Mellon     arpanet : guy@cs.cmu.edu
  171. Pittsburgh, PA  15213    csnet   : Guy.Jacobson%a.cs.cmu.edu@csnet-relay
  172. (412) 268-3056        uucp    : ...!{seismo, ucbvax, harvard}!cs.cmu.edu!guy
  173.  
  174. Here is an algorithm which takes O(sqrt(n)log(n)) steps to find all perfect
  175. squares < n whose only digits are 1, 4 and 9.
  176.  
  177. This doesn't sound too great *but* it doesn't use a lot of memory and only
  178. requires addition and <.  Also, the actual run time will depend on where the
  179. first non-{1,4,9} digit appears in each square.
  180.  
  181.     set n = 1
  182.     set odd = 1
  183.  
  184.     while(n < MAXVAL)
  185.     {
  186.         if(all digits of n are in {1,4,9})
  187.         {
  188.             print n
  189.         }
  190.  
  191.         add 2 to odd
  192.         add odd to n
  193.     }
  194.  
  195. This works because (X+1)^2 - x^2 = 2x+1.
  196. That is, if you start with 0 and add successive odd
  197. numbers to it you get 0+1=1, 1+3=4, 4+5=9, 9+7=16 etc.
  198. I've started the algorithm at 1 for convenience.
  199.  
  200. The "O" value comes from looking at at most all digits
  201. (log(n)) of all perfect squares < n (sqrt(n) of them)
  202. at most a constant number of times. 
  203.  
  204. I didn't save the articles with algorithms claiming to be
  205. O(3^log(n)) so I don't know if their calculations needed
  206. to (or did) account for multiplication or sqrt() of large
  207. numbers.  O(3^log(n)) sounds reasonable so I'm going to
  208. assume they did unless I hear otherwise.
  209.  
  210. Any comments? Please email if you just want to refresh my memory
  211. on the other algorithms.
  212.  
  213. Andrew Charles
  214. acgd@ihuxy.ATT.COMM
  215.  
  216. ==> arithmetic/digits/squares/twin.p <==
  217. Let a twin be a number formed by writing the same number twice,
  218. for instance, 81708170 or 132132.  What is the smallest square twin?
  219.  
  220. ==> arithmetic/digits/squares/twin.s <==
  221. 1322314049613223140496 = 36363636364 ^ 2.
  222.  
  223. The key to solving this puzzle is looking at the basic form of these
  224. "twin" numbers, which is some number k = 1 + 10^n multiplied by some number
  225. 10^(n-1) <= a < 10^n.  If ak is a perfect square, k must have some
  226. repeated factor, since a<k. Searching the possible values of k for one
  227. with a repeated factor eventually turns up the number 1 + 10^11 = 11^2
  228. * 826446281.  So, we set a=826446281 and ak = 9090909091^2 =
  229. 82644628100826446281, but this needs leading zeros to fit the pattern.
  230. So, we multiply by a suitable small square (in this case 16) to get the
  231. above answer.
  232.  
  233. ==> arithmetic/digits/sum.of.digits.p <==
  234. Find sod ( sod ( sod (4444 ^ 4444 ) ) ).
  235.  
  236. ==> arithmetic/digits/sum.of.digits.s <==
  237. let X = 4444^4444
  238.  
  239. sod(X) <= 9 * (# of digits) < 145900
  240. sod(sod(X)) <= sod(99999) = 45
  241. sod(sod(sod(X))) <= sod(39) = 12
  242.  
  243. but sod(sod(sod(X))) = 7 (mod 9)
  244.  
  245. thus sod(sod(sod(X))) = 7
  246.  
  247. ==> arithmetic/digits/zeros/million.p <==
  248. How many zeros occur in the numbers from 1 to 1,000,000?
  249.  
  250. ==> arithmetic/digits/zeros/million.s <==
  251. In the numbers from 10^(n-1) through 10^n - 1, there are 9 * 10^(n-1)
  252. numbers of n digits each, so 9(n-1)10^(n-1) non-leading digits, of
  253. which one tenth, or 9(n-1)10^(n-2), are zeroes.  When we change the
  254. range to 10^(n-1) + 1 through 10^n, we remove 10^(n-1) and put in
  255. 10^n, gaining one zero, so
  256.  
  257.     p(n) = p(n-1) + 9(n-1)10^(n-2) + 1 with p(1)=1.
  258.  
  259. Solving the recurrence yields the closed form
  260.  
  261.     p(n) = n(10^(n-1)+1) - (10^n-1)/9.
  262.  
  263. For n=6, there are 488,895 zeroes, 600,001 ones, and 600,000 of all other
  264. digits.
  265.  
  266. ==> arithmetic/digits/zeros/trailing.p <==
  267. How many trailing zeros are in the decimal expansion of n!?
  268.  
  269. ==> arithmetic/digits/zeros/trailing.s <==
  270. The general answer to the question
  271. "what power of p divides x!" where p is prime
  272. is (x-d)/(p-1) where d is the sum of the digits of (x written in base p).
  273.  
  274. So where p=5, 10 is written as 20 and is divisible by 5^2 (2 = (10-2)/4);
  275. x to base 10:     100    1000    10000    100000     1000000
  276. x to base 5:      400   13000   310000  11200000   224000000
  277. d          :        4       4        4         4           8
  278. trailing 0s in x!  24     249     2499     24999      249998
  279.  
  280. ==> arithmetic/magic.squares.p <==
  281. Are there large squares, containing only consecutive integers, all of whose
  282. rows, columns and diagonals have the same sum?  How about cubes?
  283.  
  284. ==> arithmetic/magic.squares.s <==
  285. These are called magic squares.  A magic square of order n (integers
  286. from 1 to n*n) has only one possible sum: (n*n+1)*n/2.
  287.  
  288. Odd and even order squares must be constructed by different approaches.
  289. For odd orders, the most common algorithm is a recursive scheme
  290. devised by de la Loubere about 300 years ago.  For even orders, one
  291. procedure is the Devedec algorithm, which treats even orders not
  292. divisible by 4 slightly differently from those which are divisible by
  293. 4 (doubly even).
  294.  
  295. For squares with odd-length sides, the following algorithm builds a magic
  296. square:
  297.  
  298. Put 1 in the middle box in the upper row. From then on, if it's
  299. possible to put the next number one box diagonally up and to the right
  300. (wrapping around if the edge of the grid is reached), do so, otherwise,
  301. put it directly below the last one.
  302.  
  303.                17 24  1  8 15
  304.                23  5  7 14 16 
  305.                 4  6 13 20 22
  306.                10 12 19 21  3 
  307.                11 18 25  2  9 
  308.  
  309. ...or even
  310.  
  311.          47 58 69 80  1 12 23 34 45
  312.          57 68 79  9 11 22 33 44 46
  313.          67 78  8 10 21 32 43 54 56
  314.          77  7 18 20 31 42 53 55 66
  315.           6 17 19 30 41 52 63 65 76
  316.          16 27 29 40 51 62 64 75  5
  317.          26 28 39 50 61 72 74  4 15
  318.          36 38 49 60 71 73  3 14 25
  319.          37 48 59 70 81  2 13 24 35
  320.  
  321. See archive entry knight.tour for magic squares that are knight's tours.
  322.  
  323. To get a 4x4 square, write the numbers in order across each row, filling
  324. the square...
  325.  
  326. 1  2  3  4
  327. 5  6  7  8
  328. 9  10 11 12
  329. 13 14 15 16
  330.  
  331. then use the following pattern as a mask:
  332.  
  333. .  X  X  .
  334. X  .  .  X
  335. X  .  .  X
  336. .  X  X  .
  337.  
  338. Everywhere there is an X, complement the number (subtract it from
  339. n*n+1).  For the 4x4 you get:
  340.  
  341. 1  15 14 4
  342. 12 6  7  9
  343. 8  10 11 5
  344. 13 3  2  16
  345.  
  346. For n even (n>4):
  347.  
  348. Make an initial magic square by writing an n/2 magic square four times
  349. (the same one each time).  Now, although this square adds up right we
  350. have the numbers 1 to n*n/4 written four times each.  To fix this,
  351. simply add to it n*n/4 times one of the following magic squares:
  352.  
  353. if n/2 is odd (example: n/2=7),
  354.  
  355. 3 3 3 0 0 0 0 2 2 2 2 2 1 1   (there are int(n/4) 3s, int(n/4-1) 1s on each
  356. 3 3 3 0 0 0 0 2 2 2 2 2 1 1    row)
  357. 3 3 3 0 0 0 0 2 2 2 2 2 1 1
  358. 0 3 3 3 0 0 0 2 2 2 2 2 1 1   (this is row int(n/4)+1.  It starts with just
  359. 3 3 3 0 0 0 0 2 2 2 2 2 1 1    the one 0)
  360. 3 3 3 0 0 0 0 2 2 2 2 2 1 1
  361. 3 3 3 0 0 0 0 2 2 2 2 2 1 1
  362. 0 0 0 3 3 3 3 1 1 1 1 1 2 2   (the lower half is the same as the upper half
  363. 0 0 0 3 3 3 3 1 1 1 1 1 2 2    with 3<->0 and 1<->2 swapped.  This guarantees
  364. 0 0 0 3 3 3 3 1 1 1 1 1 2 2    that each number 1-n*n will appear in the
  365. 3 0 0 0 3 3 3 1 1 1 1 1 2 2    completed square)
  366. 0 0 0 3 3 3 3 1 1 1 1 1 2 2
  367. 0 0 0 3 3 3 3 1 1 1 1 1 2 2
  368. 0 0 0 3 3 3 3 1 1 1 1 1 2 2
  369.  
  370. if n/2 is even (example: n/2=4),
  371.  
  372. 0 0 3 3 2 2 1 1  (there are n/4 of each number on each row)
  373. 0 0 3 3 2 2 1 1
  374. 0 0 3 3 2 2 1 1
  375. 0 0 3 3 2 2 1 1
  376. 3 3 0 0 1 1 2 2
  377. 3 3 0 0 1 1 2 2
  378. 3 3 0 0 1 1 2 2
  379. 3 3 0 0 1 1 2 2
  380.  
  381. References:
  382.     "Magic Squares and Cubes"
  383.     W.S. Andrews
  384.     The Open Court Publishing Co.
  385.     Chicago, 1908
  386.  
  387.     "Mathematical Recreations"
  388.     M. Kraitchik
  389.     Dover
  390.     New York, 1953
  391.  
  392. ==> arithmetic/pell.p <==
  393. Find integer solutions to x^2 - 92y^2 = 1.
  394.  
  395. ==> arithmetic/pell.s <==
  396. x=1        y=0
  397. x=1151     y=120
  398. x=2649601  y=276240
  399. etc.
  400.  
  401. Each successive solution is about 2300 times the previous
  402. solution;  they are every 8th partial fraction (x=numerator,
  403. y=denominator) of the continued fraction for sqrt(92) = 
  404. [9,  1,1,2,4,2,1,1,18,  1,1,2,4,2,1,1,18,  1,1,2,4,2,1,1,18, ...]
  405.  
  406. Once you have the smallest positive solution (x1,y1) you
  407. don't need to "search" for the rest.  You can obtain the nth positive
  408. solution (xn,yn) by the formula
  409.  
  410. (x1 + y1 sqrt(92))^n = xn + yn sqrt(92).
  411.  
  412. See Niven & Zuckerman's An Introduction to the Theory of Numbers.
  413. Look in the index under Pell's equation.
  414.  
  415. ==> arithmetic/subset.p <==
  416. Prove that all sets of n integers contain a subset whose sum is divisible by n.
  417.  
  418. ==> arithmetic/subset.s <==
  419. Consider the set of remainders of the partial sums a(1) + ... + a(i).
  420. Since there are n such sums, either one has remainder zero (and we're
  421. thru) or 2 coincide, say the i'th and j'th.  In this case, a(i+1) +
  422. ... + a(j) is divisible by n.  (note this is a stronger result since
  423. the subsequence constructed is of *adjacent* terms.)  Consider a(1)
  424. (mod n), a(1)+a(2) (mod n), ..., a(1)+...+a(n) (mod n).  Either at
  425. some point we have a(1)+...+a(m) = 0 (mod n) or else by the pigeonhole
  426. principle some value (mod n) will have been duplicated.  We win either
  427. way.
  428.  
  429. ==> arithmetic/sum.of.cubes.p <==
  430. Find two fractions whose cubes total 6.
  431.  
  432. ==> arithmetic/sum.of.cubes.s <==
  433. Restated:  
  434. Find X, Y, minimum Z (all positive integers) where
  435. (X/Z)^3 + (Y/Z)^3 = 6
  436.  
  437. Again, a generalized solution would be nice.
  438.  
  439. You are asking for the smallest z s.t. x^3 + y^3 = 6*z^3 and x,y,z in Z+.
  440. In general, questions like these are extremely difficult; if you're
  441. interested take a look at books covering Diophantine equations
  442. (especially Baker's work on effective methods of computing solutions).
  443.  
  444. Dudeney mentions this problem in connection with #20 in _The Canterbury
  445. Puzzles_; the smallest answer is (17/21)^3 + (37/21)^3 = 6.
  446.  
  447. For the interest of the readers of this group I'll quote:
  448.  
  449.    "Given a known case for the expression of a number as the sum or
  450. difference of two cubes, we can, by formula, derive from it an infinite
  451. number of other cases alternately positive and negative.  Thus Fermat,
  452. starting from the known case 1^3 + 2^3 = 9 (which we will call a
  453. fundamental case), first obtained a negative solution in bigger
  454. figures, and from this his positive solution in bigger figures still.
  455. But there is an infinite number of fundamentals, and I found by trial
  456. a negative fundamental solution in smaller figures than his derived
  457. negative solution, from which I obtained the result shown above.  That
  458. is the simple explanation."
  459.  
  460. In the above paragraph Dudeney is explaining how he derived (*by hand*)
  461. that (415280564497/348671682660)^3 + (676702467503/348671682660)^3 = 9.
  462.  
  463. He continues:
  464.  
  465. "We can say of any number up to 100 whether it is possible or not to
  466. express it as the sum of two cubes, except 66.  Students should read
  467. the Introduction to Lucas's _Theorie des Nombres_, p. xxx."
  468.  
  469. "Some years ago I published a solution for the case 6 = (17/21)^3 +
  470. (37/21)^3, of which Legendre gave at some length a 'proof' of
  471. impossibility; but I have since found that Lucas anticipated me in
  472. a communication to Sylvester."
  473.  
  474. ==> arithmetic/sums.of.powers.p <==
  475. Partition 1,2,3,...,16 into two equal sets, such that the sums of the
  476. numbers in each set are equal, as are the sums of their squares and cubes.
  477.  
  478. ==> arithmetic/sums.of.powers.s <==
  479. The solution is A = {1,4,6,7,10,11,13,16}
  480.                 B = {2,3,5,8,9,12,14,15}                                                         
  481.  
  482. Let X+k be a set formed by adding k to all elements of X.
  483. Then A+k and B+k have the property of satisfying i,ii and iii.
  484. That means, any 16 numbers in A.P can be partioned in such a way to
  485. satisfy i,ii and iii.
  486.  
  487. How do we arrive at the above solution without using a computer?
  488.  
  489. By the preceding discussion,
  490.  
  491.     A1 = A-1 = {0,3,5,6,9,10,12,15}
  492.         B1 = B-1 = {1,2,4,7,8,11,13,14}
  493.  
  494. have the property of satisfying i,ii and iii.
  495. Notice that all numbers of A1 have even number of 1's in binary and
  496. all numbers of B1 have odd number of 1's in binary. Essentially the
  497. above partition is a partition based on parity.
  498.  
  499. Observation:
  500.  
  501.     Partition of (n+1) bit numbers based on parity into two
  502. groups A and B (each consisting of 2^n elements) satisfies
  503.  
  504.  sum of kth powers of elements of A = sum of kth powers of elements of B
  505.  
  506. for k=1,2,...,n. (The above puzzle is a special case n=3).
  507.  
  508.  
  509. The above observation also holds for any radix. In radix r we will have
  510. r groups.
  511.  
  512. Infact,
  513.  
  514.     Any r^(n+1) terms in A.P can be partitioned into r groups (each of
  515. r^n elements) such that sum of kth powers of all r groups is same (k=1,2,...,n)
  516.  
  517. Finding such groups with minimal number of elements (less than r^n) appears to
  518. be more difficult!
  519.  
  520. ALL THIS APPEARS TO BE INTERESTING. IS IT A CONSEQUENCE OF A SIMPLE THEOREM OF
  521. NUMBER THEORY? HOW DO I PROVE THIS?
  522.  
  523. Thanks in advance for any clues,
  524.  
  525. -- ramana@svl.cdc.com (Mr. Ramana (Indian analyst))
  526.  
  527. ==> arithmetic/tests.for.divisibility/eleven.p <==
  528. What is the test to see if a number is divisible by eleven?
  529.  
  530.  
  531. ==> arithmetic/tests.for.divisibility/eleven.s <==
  532. If the alternating sum of the digits is divisible by eleven, so is the number.
  533.  
  534. For example, 1639 leads to 9 - 3 + 6 - 1 = 11, so 1639 is divisible by 11.
  535.  
  536. Proof:
  537. Every integer n can be expressed as 
  538. n = a1*(10^k) + a2*(10^k-1)+ .....+ a_k+1
  539. where a1, a2, a3, ...a_k+1 are integers between 0 and 9.
  540. 10 is congruent to -1 mod(11).
  541. Thus if (-1^k)*a1 + (-1^k-1)*a2 + ...+ (a_k+1) is congruent to 0mod(11) then 
  542. n is divisible by 11.
  543.  
  544. ==> arithmetic/tests.for.divisibility/nine.p <==
  545. What is the test to see if a number is divisible by nine?
  546.  
  547. ==> arithmetic/tests.for.divisibility/nine.s <==
  548. If the sum of the digits is divisible by nine, so is the number.
  549.  
  550. Proof:
  551. Every integer n can be expressed as 
  552. n = a1*(10^k) + a2*(10^k-1)+ .....+ a_k+1
  553. where a1, a2, a3, ...a_k+1 are integers between 0 and 9.
  554. Note that 10 is congruent to 1 (mod 9). Thus 10^k is congruent to 1 (mod 9) for
  555. every k >= 0.
  556. Thus n is congruent to (a1+a2+a3+....+a_k+1) mod(9).
  557. Hence (a1+a2+...+a_k+1) is divisible by 9 iff n is divisible by 9.
  558.  
  559. ==> arithmetic/tests.for.divisibility/seven.p <==
  560. What is the test to see if a number is divisible by seven?
  561.  
  562. ==> arithmetic/tests.for.divisibility/seven.s <==
  563. Take the last digit (n mod 10) and double it.
  564. Take the rest of the digits (n div 10) and subtract the doubled last
  565.     digit from it.
  566. The resulting number is divisible by 7 iff the original number
  567.     is divisible by 7.
  568.  
  569. Example:  Take 53445
  570.           Subtract (53445 mod 10) * 2 from (53445 div 10)
  571.                            -  5  * 2   +   5344
  572.                             = 5334
  573.       533 - 2 * 4 = 525
  574.       52 - 5 * 2 = 42 which is divisible by 7
  575.           so 53445 is divisible by 7.
  576.  
  577. ==> arithmetic/tests.for.divisibility/three.p <==
  578. What is the test to see if a number is divisible by three?
  579.  
  580. ==> arithmetic/tests.for.divisibility/three.s <==
  581. A number is divisible by three iff the sum of its digits is divisible by three.
  582. First, prove 10^N = 1 mod 3 for all integers N >= 0.
  583. 1 = 1 mod 3. 10 = 1 mod 3. 10^N = 10^(N-1) * 10 = 10^(N-1) mod 3.
  584. QED by induction. 
  585. Now let D[0] be the units digit of N, D[1] the tens digit, etc.
  586. Now N = Summation From k=0 to k=inf of D[k]*10^k.
  587. Therefore N mod 3 = Summation from k=0 to k=inf of D[k] mod 3. QED
  588.  
  589.