All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
2 digit Palindrome (Posted on 2004-04-05) Difficulty: 2 of 5
A palindrome is a word which reads the same backwards as it does forwards. Similarly, a number having this quality is considered 'palindromic'.

Consider the number 23. Reverse and add that number to 23 to yield the palindrome 55. This has taken one step.

Now consider the same reversal-summation process for 37. Over 2 steps it becomes the palindrome 121(37,73/110,011/121).

QUESTION: What 2 digit number requires the most stages to become a palindrome? How many stages is that, and what is the palindrome?


NOTES, THOUGHTS, CONSIDERATIONS:
1] It will become quickly evident that certain combinations will run out fast (like, why use 32 when 23 is its reverse).

2] Spreadsheet calculator - If you need one. Copy the formula ' =A1+A2 ' into cell 3 of a column. Copy it into each successively descending odd cell as may be needed. Format the column as 'Number' having no decimal places so as to override that particular time when the Exp. Not. default would normally cut in.

Enter your chosen number into A1 and continue to place the reverse total of each odd row into the cell of the next even row.

3] Obviously such sequences do occur beyond 2 digit numbers and while I have some 3 digit challenges in my personal literature, I am wondering if there is some 'easy' way of when a number becomes a palindrome - obviously I assume that it will happen with any number eventually (but should I pose that question, or even present some of the 3 digit challenges?).

See The Solution Submitted by brianjn    
Rating: 3.0000 (5 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 24
The following program
 200   MaxCt=0
 300   for N=10 to 99
 400    N$=mid(str(N),2,*)
 500    N1$=N$
 600    Ct=0
 700    while 1=1
 800      Rev$=""
 900      for I=1 to len(N1$)
1000       Rev$=mid(N1$,I,1)+Rev$
1100      next
1200      if val(Rev$)=val(N1$) then goto 1700
1300      N1=val(N1$)+val(Rev$)
1400      N1$=mid(str(N1),2,*)
1500      Ct=Ct+1
1600    wend
1700    if Ct>MaxCt then MaxCt=Ct:MaxN=N
1800   next
1900   print MaxN,MaxCt
2000
2100   N=MaxN
2200
2300   dim Hist$(MaxCt)
2400
2500   for N=10 to 99
2600    N$=mid(str(N),2,*)
2700    N1$=N$
2800    Ct=0
2900    while 1=1
3000      Rev$=""
3100      for I=1 to len(N1$)
3200       Rev$=mid(N1$,I,1)+Rev$
3300      next
3400      if val(Rev$)=val(N1$) then goto 4000
3500      N1=val(N1$)+val(Rev$)
3600      N1$=mid(str(N1),2,*)
3700      Ct=Ct+1
3800      Hist$(Ct)=N1$
3900    wend
4000    if Ct=MaxCt then
4100    :print N
4200    :for I=1 to MaxCt
4300    :print I,Hist$(I)
4400    :next:print
4600   next
finds both 89 and 98 lead to the following 24 steps:
1      187
2      968
3      1837
4      9218
5      17347
6      91718
7      173437
8      907808
9      1716517
10     8872688
11     17735476
12     85189247
13     159487405
14     664272356
15     1317544822
16     3602001953
17     7193004016
18     13297007933
19     47267087164
20     93445163438
21     176881317877
22     955594506548
23     1801200002107
24     8813200023188

The 3-digit equivalent gets bogged down at 196, where new numbers come up until the capacity of the programming language is exceeded.  It starts out:
1      887
2      1675
3      7436
4      13783
5      52514
6      94039
7      187088
8      1067869
9      10755470
10     18211171
11     35322452
12     60744805
13     111589511
14     227574622
15     454050344
16     897100798
17     1794102596
18     8746117567
19     16403234045
20     70446464506
21     130992928913
22     450822227944
23     900544455998
24     1800098901007
25     8801197801088
26     17602285712176
27     84724043932847
28     159547977975595
29     755127757721546
30     1400255515443103
31     4413700670963144
32     8827391431036288
33     17653692772973576
34     85191620502609247
35     159482241005228405
36     664304741147513356
37     1317620482294916822
38     3603815405135183953
39     7197630720180367016
40     13305261530450734933
41     47248966933966985264
42     93507933867933969538
43     177104867844767940077
44     947154635293536341848
45     1795298270686072793597
46     9749270977546801719568
47     18408442064004592449047

The capacity of UBASIC is exceeded in the step (2577) after the following:
 2576   880044439011753122881227195126554383818544395553644268175735928564859630
92201763490328895493179077133304498587466650867630682756693627193288735535472160
96636115380992216837365825962966635822589723578704678819603922583146736672697680
24855930759886538856785513195871004240024440339504541374445206533255322376495282
57114666856815857548167799393698853911523789046305012825386581436004858445718399
73825592309123026624123701320454563238742998354386964074920931816275247277569485
03533379814620158942724200332888136795212109955508261599529173837397484793847281
82599517281554901121248774078823409153723995102640807233541475074682653462727040
11848146957346380034673335545402310842141572922200230651837003718643857509644075
69451831049373988841412045780728399777174575960765866652065292504584223552335602
54447314539504293442103350006958142558764794557895812855951976807166737741276319
39601797649687542699612953666916061757472772219008451163560160284524646892390736
28665827713675705666478589451333068088229548883398436819130026959565720626581773
446245604445808482355731491732079320357101033549978

Edited on April 5, 2004, 9:05 am
  Posted by Charlie on 2004-04-05 09:04:20

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (23)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information